Lines 46-52
Link Here
|
46 |
the synonyms for this word may be found |
46 |
the synonyms for this word may be found |
47 |
*/ |
47 |
*/ |
48 |
|
48 |
|
49 |
|
|
|
50 |
#include <sal/types.h> |
49 |
#include <sal/types.h> |
51 |
#include <osl/file.h> |
50 |
#include <osl/file.h> |
52 |
#include <osl/file.hxx> |
51 |
#include <osl/file.hxx> |
Lines 121-126
Link Here
|
121 |
return 1; |
120 |
return 1; |
122 |
} |
121 |
} |
123 |
|
122 |
|
|
|
123 |
/************************************************************************ |
124 |
* |
125 |
* Print usage details and exit. |
126 |
* |
127 |
************************************************************************/ |
128 |
void usage( char * program ) |
129 |
{ |
130 |
fprintf( stderr, "Thesaurus encode program\n\n" ); |
131 |
fprintf( stderr, "%s [-v] input_directory output_directory output_file\n\n", program ); |
132 |
fprintf( stderr, "-v enables the verbose option\n" ); |
133 |
exit(1); |
134 |
|
135 |
} |
136 |
|
124 |
/* |
137 |
/* |
125 |
read a line of text from a text file stripping |
138 |
read a line of text from a text file stripping |
126 |
off the line terminator and replacing it with |
139 |
off the line terminator and replacing it with |
Lines 145-151
Link Here
|
145 |
} |
158 |
} |
146 |
nb++; |
159 |
nb++; |
147 |
if (nb == (sal_uInt64)(nc - 1)) { |
160 |
if (nb == (sal_uInt64)(nc - 1)) { |
148 |
*(pBuffer+nb) = '\0'; |
161 |
*(pBuffer+nb) = '\0'; |
149 |
return (sal_Int32) nb; |
162 |
return (sal_Int32) nb; |
150 |
} |
163 |
} |
151 |
} while ( *(pBuffer+(nb-1)) != '\n' ); |
164 |
} while ( *(pBuffer+(nb-1)) != '\n' ); |
Lines 175-190
Link Here
|
175 |
sal_Int32 idx; |
188 |
sal_Int32 idx; |
176 |
FileBase::RC rc; |
189 |
FileBase::RC rc; |
177 |
|
190 |
|
178 |
if ((!(argv[1])) || (!(argv[2])) || (!(argv[3]))) { |
191 |
short verbose = 0; /* How verbose do you want the run, default none */ |
179 |
fprintf(stderr,"thencode input_directory output_directory output_file\n"); |
|
|
180 |
exit(1); |
181 |
} |
182 |
|
192 |
|
|
|
193 |
char * inp_dir; // temporary pointers to the three parameters. |
194 |
char * out_dir; |
195 |
char * out_file; |
183 |
|
196 |
|
|
|
197 |
if( argc < 3 ) { |
198 |
usage( argv[0] ); // print message, exit program |
199 |
} |
200 |
|
201 |
if( argc == 3 ) { |
202 |
inp_dir = argv[1]; |
203 |
out_dir = argv[2]; |
204 |
out_file = argv[3]; |
205 |
} |
206 |
else if( ! strcmp( argv[1], "-v" ) ) { // match |
207 |
verbose++; |
208 |
inp_dir = argv[2]; |
209 |
out_dir = argv[3]; |
210 |
out_file = argv[4]; |
211 |
} |
212 |
else { |
213 |
usage( argv[0] ); |
214 |
} |
215 |
|
216 |
|
184 |
rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); |
217 |
rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); |
185 |
OUString aUniInp( argv[1], strlen( argv[1] ), aEncoding ); |
218 |
OUString aUniInp( inp_dir, strlen( inp_dir ), aEncoding ); |
186 |
OUString aUniOut( argv[2], strlen( argv[2] ), aEncoding ); |
219 |
OUString aUniOut( out_dir, strlen( out_dir ), aEncoding ); |
187 |
OUString aUniName(argv[3], strlen( argv[3] ), aEncoding ); |
220 |
OUString aUniName( out_file, strlen( out_file ), aEncoding ); |
188 |
|
221 |
|
189 |
OUString iUrl; |
222 |
OUString iUrl; |
190 |
OUString aiUrl; |
223 |
OUString aiUrl; |
Lines 312-318
Link Here
|
312 |
nIndex = 0; |
345 |
nIndex = 0; |
313 |
cTok = ','; |
346 |
cTok = ','; |
314 |
OString entry = tline.getToken(0, cTok, nIndex); |
347 |
OString entry = tline.getToken(0, cTok, nIndex); |
315 |
fprintf(stdout,"...processing %s\n",entry.getStr()); |
348 |
if( verbose ) { |
|
|
349 |
fprintf(stdout,"...processing %s\n",entry.getStr()); |
350 |
} |
316 |
idx = binsearch((sal_Char *)entry.getStr(),list,nw); |
351 |
idx = binsearch((sal_Char *)entry.getStr(),list,nw); |
317 |
if (idx < 0) { |
352 |
if (idx < 0) { |
318 |
fprintf(stderr,"Error - wordlist does not match data\n"); |
353 |
fprintf(stderr,"Error - wordlist does not match data\n"); |
Lines 329-335
Link Here
|
329 |
OString nentry = tline.getToken(0, cTok, nIndex); |
364 |
OString nentry = tline.getToken(0, cTok, nIndex); |
330 |
m = binsearch((sal_Char *)nentry.getStr(),list,nw); |
365 |
m = binsearch((sal_Char *)nentry.getStr(),list,nw); |
331 |
if (m != -1) { |
366 |
if (m != -1) { |
332 |
ilst[ns] = (sal_uInt16) m; |
367 |
ilst[ns] = (sal_uInt16) m; |
333 |
ns++; |
368 |
ns++; |
334 |
} else { |
369 |
} else { |
335 |
fflush( stdout ); |
370 |
fflush( stdout ); |
Lines 349-355
Link Here
|
349 |
end_cpy(op,(sal_Char *)ilst,ns); |
384 |
end_cpy(op,(sal_Char *)ilst,ns); |
350 |
|
385 |
|
351 |
if (pdfile->setPos(Pos_Absolut,offset) != FileBase::E_None) { |
386 |
if (pdfile->setPos(Pos_Absolut,offset) != FileBase::E_None) { |
352 |
fprintf(stderr,"Error - Seek Failed\n"); |
387 |
fprintf(stderr,"Error - Seek Failed\n"); |
353 |
if (list) rtl_freeMemory((void*)list); |
388 |
if (list) rtl_freeMemory((void*)list); |
354 |
if (offst) rtl_freeMemory((void*)offst); |
389 |
if (offst) rtl_freeMemory((void*)offst); |
355 |
if (ilst) rtl_freeMemory((void*)ilst); |
390 |
if (ilst) rtl_freeMemory((void*)ilst); |
Lines 358-364
Link Here
|
358 |
|
393 |
|
359 |
rc = writenc(pdfile, en , bl); |
394 |
rc = writenc(pdfile, en , bl); |
360 |
if (rc != FileBase::E_None) { |
395 |
if (rc != FileBase::E_None) { |
361 |
fprintf(stderr,"Error - write returned an error %d\n",rc); |
396 |
fprintf(stderr,"Error - write returned an error %d\n",rc); |
362 |
if (list) rtl_freeMemory((void*)list); |
397 |
if (list) rtl_freeMemory((void*)list); |
363 |
if (offst) rtl_freeMemory((void*)offst); |
398 |
if (offst) rtl_freeMemory((void*)offst); |
364 |
if (ilst) rtl_freeMemory((void*)ilst); |
399 |
if (ilst) rtl_freeMemory((void*)ilst); |
Lines 401-407
Link Here
|
401 |
bl = sprintf(op,"%s,%d\n",list[j],offst[j]); |
436 |
bl = sprintf(op,"%s,%d\n",list[j],offst[j]); |
402 |
rc = writenc(pifile, obuf, bl); |
437 |
rc = writenc(pifile, obuf, bl); |
403 |
if (rc != FileBase::E_None) { |
438 |
if (rc != FileBase::E_None) { |
404 |
fprintf(stderr,"Error - write returned an error %d\n",rc); |
439 |
fprintf(stderr,"Error - write returned an error %d\n",rc); |
405 |
if (list) rtl_freeMemory((void*)list); |
440 |
if (list) rtl_freeMemory((void*)list); |
406 |
if (offst) rtl_freeMemory((void*)offst); |
441 |
if (offst) rtl_freeMemory((void*)offst); |
407 |
if (ilst) rtl_freeMemory((void*)ilst); |
442 |
if (ilst) rtl_freeMemory((void*)ilst); |