1: /*
2: * Convert from the dot files and one field active file to a
3: * two field active file.
4: */
5: #include <stdio.h>
6: #include <sys/types.h>
7: #include <sys/stat.h>
8:
9: char *LIB, *SPOOL;
10: char oactive[100], nactive[100];
11: char dotfile[100];
12: char ng[100];
13: FILE *ofd, *nfd;
14:
15: struct stat sbuf;
16:
17: main(argc, argv)
18: char **argv;
19: {
20: register char *p;
21:
22: if (argc != 3) {
23: printf("Usage: cvtdot LIB SPOOL\n");
24: exit(1);
25: }
26:
27: LIB = argv[1];
28: SPOOL = argv[2];
29:
30: sprintf(oactive, "%s/%s", LIB, "active");
31: sprintf(nactive, "%s/%s", LIB, "nactive");
32: ofd = fopen(oactive, "r");
33: if (ofd == NULL) {
34: fprintf(stderr, "Cannot open %s\n", oactive);
35: exit(1);
36: }
37: nfd = fopen(nactive, "w");
38: if (nfd == NULL) {
39: fprintf(stderr, "Cannot create %s\n", nactive);
40: exit(1);
41: }
42:
43: while (fgets(ng, sizeof ng, ofd) != NULL) {
44: for (p=ng; *p!='\n'; p++)
45: ;
46: *p = 0;
47: sprintf(dotfile, "%s/.%s", SPOOL, ng);
48: stat(dotfile, &sbuf);
49: fprintf(nfd, "%s %05ld\n", ng, sbuf.st_size);
50: }
51: fclose(ofd);
52: fclose(nfd);
53: }
Defined functions
main
defined in line
17;
never used
Defined variables
LIB
defined in line
9; used 3 times
SPOOL
defined in line
9; used 2 times
ng
defined in line
12; used 5 times
sbuf
defined in line
15; used 2 times