Repositories » TXT0 Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

Remove option to process a query in raw2t.c. Rename send() and receive() to writeTFile() and readTFile() respectively.

Changeset 903c968226d9

Parent 63220ad0c40e

by Rup Palchowdhury

Changes to 3 files · Browse files at 903c968226d9 Showing diff from parent 63220ad0c40e Diff from another changeset...

Change 1 of 2 Show Entire File raw2t.c Stacked
 
22
23
24
25
 
26
27
28
29
30
31
32
 
 
33
34
35
36
37
38
39
 
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
 
 
 
 
109
110
111
 
22
23
24
 
25
26
27
28
29
 
 
 
30
31
32
 
33
 
34
35
36
 
48
49
50
 
 
 
 
 
 
 
 
51
52
53
54
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
57
58
59
60
61
62
@@ -22,18 +22,15 @@
   void usage(char *progname)  { - eprintf("usage: %s [-c] [-n] [-x] [-q corpus.t] <in.txt >out.t\n", progname); + eprintf("usage: %s [-c] [-n] [-x] <in.txt >out.t\n", progname);  }    int main(int argc, char *argv[])  { - FILE *fplog, *vfp; - TFile *tfile, *tfile_; - Hash *hv; + FILE *fplog; + TFile *tfile;   Parser *parser; - char vfile[KB];   int c, n, x_min, x_max, q, size, bpack; - uint8_t *buf;     esetprogname(estrdup(argv[0]));   fplog = fopen(strcat(estrdup(argv[0]), "-error.log"), "w"); @@ -51,61 +48,15 @@
  x_min = 4;   x_max = 20;   } - else if (strcmp(argv[i], "-q") == 0) { - if (i + 1 <= argc - 1) { - strcpy(vfile, argv[++i]); - q = 1; - } - else - usage(argv[0]); - }   else {   /* process non-optional arguments here*/   }   }   - if (q) { - parser = newparser('q', cwSMART, c, n, x_min, x_max); - tfile_ = newTFile(); - hv = newhash(NHASHT, cmptoken_str, hashtoken_str); - buf = (uint8_t *)emalloc(size); - vfp = fopen(vfile, "r"); - - - if ((n = fread(buf, BTHEADER, 1, vfp)) != 1) - eprintf("fread() failed on %d byte THeader\n", - BTHEADER); - if (unpackTHeader(tfile_->h, BTHEADER, buf) != BTHEADER) - eprintf("unpackTHeader() failed on %d byte THeader\n", - BTHEADER); - - bpack = tfile_->h->bt > tfile_->h->bd ? tfile_->h->bt : tfile_->h->bd; - - if (size < bpack) { - while ((size <<= 1) < bpack); - buf = erealloc(buf, size); - } - - if ((n = fread(buf, tfile_->h->bt, 1, vfp)) != 1) - eprintf("fread() failed on %d byte tfile->h->bt\n", - tfile_->h->bt); - if (unpack_idmap(hv, tfile_->h->bt, buf) != tfile_->h->bt) - eprintf("unpack_idmap() failed on %d byte tfile->h->bt\n", - tfile_->h->bt); - - fclose(vfp); - free(buf); - - tfile = parseq(tfile_->h, hv, parser, stdin); - - freeTFile(tfile_); - } - else { - parser = newparser('d', cwSMART, c, n, x_min, x_max); - tfile = parse(parser, stdin); - } - - send(stdout, tfile); fflush(stdout); + parser = newparser('d', cwSMART, c, n, x_min, x_max); + tfile = parse(parser, stdin); + writeTFile(stdout, tfile); + fflush(stdout);   freeTFile(tfile);     fclose(fplog);
Change 1 of 2 Show Entire File tfile.c Stacked
 
514
515
516
517
 
518
519
520
 
579
580
581
582
 
583
584
585
 
514
515
516
 
517
518
519
520
 
579
580
581
 
582
583
584
585
@@ -514,7 +514,7 @@
  return m;  }   -void send(FILE *fp, TFile *tfile) +void writeTFile(FILE *fp, TFile *tfile)  {   int n, c, size, bpack;   Node *np; @@ -579,7 +579,7 @@
  fprintf(stderr, "\n");  }   -TFile *receive(FILE *fp, TFile *tfile) +TFile *readTFile(FILE *fp, TFile *tfile)  {   int n, c, size, bpack;   /* TFile *tfile; */
Change 1 of 1 Show Entire File tfile.h Stacked
 
86
87
88
89
90
 
 
 
86
87
88
 
 
89
90
@@ -86,5 +86,5 @@
 int unpackTDocHeader(TDocHeader *h, int n, uint8_t *buf);  int unpackTDoc_payload(TDoc *tdoc, int n, uint8_t *buf);   -void send(FILE *fp, TFile *tfile); -TFile *receive(FILE *fp, TFile *tfile); +void writeTFile(FILE *fp, TFile *tfile); +TFile *readTFile(FILE *fp, TFile *tfile);