summaryrefslogtreecommitdiffstats
path: root/trans/transman.c
blob: 711e8eadc85ddd0373376b5611cee5a48b8f2e0f (plain) (blame)
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
51
52
53
54
55
56
/* $Id$ */
// tools to translate the format of eagle bbs -> Ptt bbs */

#include "bbs.h"

int transman(char *path)
{
  char name[128];
  char buf[512], filename[512], *direct="";
  int n=0;
  fileheader_t fh;
  FILE *fp;

  chdir(path);

  fp = fopen(".Names", "r");
  if(fp)
   for(n=0; fgets(buf,512,fp)>0; n++)
   {
     strtok(buf,"\r\n");
     if(buf[0]=='#') continue;
     if(buf[0]=='N') 
        strcpy(name, buf+5);
     else 
       if(buf[0]=='P') 
        { 
         direct = buf+7;
         strcpy(filename, ".");
         stampfile(filename, &fh);
         unlink(filename);
         if(dashd(direct))
                 {
                  sprintf(fh.title, "◆ %s", name);
                  transman(direct);     
                 }
         else
                  sprintf(fh.title, "◇ %s", name);
         rename(direct, filename);
         append_record(".DIR", &fh, sizeof(fh)); 
        }
   }
  chdir("..");
  return n;
}

int main(int argc, char* argv[])
{
  if(argc < 2)
   {
    printf("%s <path>\n", argv[0]);
    return 0;
   }

  transman(argv[1]); 
  return 0;
}