~hww3/caudium

ref: 93d5a75fba08db71b832716377276978cdd7888d caudium/tools/convert_accessed.pike -rw-r--r-- 1.3 KiB
93d5a75fWilliam Welliver storage: method "None" was missing stop function. should fix error on shutdown 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!bin/pike

/* $Id$
 */

#include <process.h>
#include <stdio.h>

void main(int argc, array (string) argv)
{
  object in, in2, out;

  in=FILE();  // Buffered Input
  in2=FILE(); // Buffered Input
  out=File(); // Non-Buffered Output
  
  foreach(argv[1..], string file)
  {
    if(!in->open(file, "r"))
    {
      werror("Cannot open "+file+" for reading.\n");
      exit(2);
    }
    if(!in2->open(file+".times", "r"))
    {
      werror("Cannot open "+file+".times for reading.\n");
      exit(2);
    }
    if(!out->open(file+".db", "wc"))
    {
      werror("Cannot open "+file+".db for writing.\n");
      exit(2);
    }
    int a, b, pid, more=1,j, tl=in->stat()[1];
    string s;
    werror("Copying "+file+".main to "+file+".names.\n");
    popen("cp "+file+".main "+file+".names");
    werror("Converting "+file+" and "+file+".times\nto "+file+".db.\n");
    werror("You may remove "+file+", "+file+".times and "+file+".main\n");
    werror("after this process is finished.\n");
    while(more)
    {
      if(!((j++)%(tl/200+1)))werror((j*100)/(tl/4)+"%\r");
      a = (int)("0x"+(s=in->read(8)));  if(!strlen(s)||s==0) more=0;
      b = (int)("0x"+(s=in2->read(8)));  if(!strlen(s)||s==0) more=0;
      out->write(sprintf("%4c%4c", a, b));
    }
    werror("Done.\n");
  }
}