Leptonica  1.77.0
Image processing and image analysis suite
stringcode.c
Go to the documentation of this file.
1 /*====================================================================*
2  - Copyright (C) 2001 Leptonica. All rights reserved.
3  -
4  - Redistribution and use in source and binary forms, with or without
5  - modification, are permitted provided that the following conditions
6  - are met:
7  - 1. Redistributions of source code must retain the above copyright
8  - notice, this list of conditions and the following disclaimer.
9  - 2. Redistributions in binary form must reproduce the above
10  - copyright notice, this list of conditions and the following
11  - disclaimer in the documentation and/or other materials
12  - provided with the distribution.
13  -
14  - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
18  - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *====================================================================*/
26 
87 #include <string.h>
88 #include "allheaders.h"
89 #include "stringcode.h"
90 
91 #define TEMPLATE1 "stringtemplate1.txt" /* for assembling autogen.*.c */
92 #define TEMPLATE2 "stringtemplate2.txt" /* for assembling autogen.*.h */
93 
95 struct L_GenAssoc
96 {
97  l_int32 index;
98  char type[16]; /* e.g., "PIXA" */
99  char structname[16]; /* e.g., "Pixa" */
100  char reader[16]; /* e.g., "pixaRead" */
101  char memreader[20]; /* e.g., "pixaReadMem" */
102 };
103 
105 static const l_int32 l_ntypes = 19;
107 static const struct L_GenAssoc l_assoc[] = {
108  {0, "INVALID", "invalid", "invalid", "invalid" },
109  {1, "BOXA", "Boxa", "boxaRead", "boxaReadMem" },
110  {2, "BOXAA", "Boxaa", "boxaaRead", "boxaaReadMem" },
111  {3, "L_DEWARP", "Dewarp", "dewarpRead", "dewarpReadMem" },
112  {4, "L_DEWARPA", "Dewarpa", "dewarpaRead", "dewarpaReadMem" },
113  {5, "L_DNA", "L_Dna", "l_dnaRead", "l_dnaReadMem" },
114  {6, "L_DNAA", "L_Dnaa", "l_dnaaRead", "l_dnaaReadMem" },
115  {7, "DPIX", "DPix", "dpixRead", "dpixReadMem" },
116  {8, "FPIX", "FPix", "fpixRead", "fpixReadMem" },
117  {9, "NUMA", "Numa", "numaRead", "numaReadMem" },
118  {10, "NUMAA", "Numaa", "numaaRead", "numaaReadMem" },
119  {11, "PIX", "Pix", "pixRead", "pixReadMem" },
120  {12, "PIXA", "Pixa", "pixaRead", "pixaReadMem" },
121  {13, "PIXAA", "Pixaa", "pixaaRead", "pixaaReadMem" },
122  {14, "PIXACOMP", "Pixacomp", "pixacompRead", "pixacompReadMem" },
123  {15, "PIXCMAP", "Pixcmap", "pixcmapRead", "pixcmapReadMem" },
124  {16, "PTA", "Pta", "ptaRead", "ptaReadMem" },
125  {17, "PTAA", "Ptaa", "ptaaRead", "ptaaReadMem" },
126  {18, "RECOG", "Recog", "recogRead", "recogReadMem" },
127  {19, "SARRAY", "Sarray", "sarrayRead", "sarrayReadMem" }
128 };
129 
130 static l_int32 l_getIndexFromType(const char *type, l_int32 *pindex);
131 static l_int32 l_getIndexFromStructname(const char *sn, l_int32 *pindex);
132 static l_int32 l_getIndexFromFile(const char *file, l_int32 *pindex);
133 static char *l_genDataString(const char *filein, l_int32 ifunc);
134 static char *l_genCaseString(l_int32 ifunc, l_int32 itype);
135 static char *l_genDescrString(const char *filein, l_int32 ifunc, l_int32 itype);
136 
137 
138 /*---------------------------------------------------------------------*/
139 /* Stringcode functions */
140 /*---------------------------------------------------------------------*/
155 L_STRCODE *
156 strcodeCreate(l_int32 fileno)
157 {
158 L_STRCODE *strcode;
159 
160  PROCNAME("strcodeCreate");
161 
162  lept_mkdir("lept/auto");
163 
164  if ((strcode = (L_STRCODE *)LEPT_CALLOC(1, sizeof(L_STRCODE))) == NULL)
165  return (L_STRCODE *)ERROR_PTR("strcode not made", procName, NULL);
166 
167  strcode->fileno = fileno;
168  strcode->function = sarrayCreate(0);
169  strcode->data = sarrayCreate(0);
170  strcode->descr = sarrayCreate(0);
171  return strcode;
172 }
173 
174 
181 static void
183 {
184 L_STRCODE *strcode;
185 
186  PROCNAME("strcodeDestroy");
187 
188  if (pstrcode == NULL) {
189  L_WARNING("ptr address is null!\n", procName);
190  return;
191  }
192 
193  if ((strcode = *pstrcode) == NULL)
194  return;
195 
196  sarrayDestroy(&strcode->function);
197  sarrayDestroy(&strcode->data);
198  sarrayDestroy(&strcode->descr);
199  LEPT_FREE(strcode);
200  *pstrcode = NULL;
201  return;
202 }
203 
204 
222 l_ok
223 strcodeCreateFromFile(const char *filein,
224  l_int32 fileno,
225  const char *outdir)
226 {
227 char *fname;
228 const char *type;
229 l_uint8 *data;
230 size_t nbytes;
231 l_int32 i, n, index;
232 SARRAY *sa;
233 L_STRCODE *strcode;
234 
235  PROCNAME("strcodeCreateFromFile");
236 
237  if (!filein)
238  return ERROR_INT("filein not defined", procName, 1);
239 
240  if ((data = l_binaryRead(filein, &nbytes)) == NULL)
241  return ERROR_INT("data not read from file", procName, 1);
242  sa = sarrayCreateLinesFromString((char *)data, 0);
243  LEPT_FREE(data);
244  if (!sa)
245  return ERROR_INT("sa not made", procName, 1);
246  if ((n = sarrayGetCount(sa)) == 0) {
247  sarrayDestroy(&sa);
248  return ERROR_INT("no filenames in the file", procName, 1);
249  }
250 
251  strcode = strcodeCreate(fileno);
252 
253  for (i = 0; i < n; i++) {
254  fname = sarrayGetString(sa, i, L_NOCOPY);
255  if (fname[0] == '#') continue;
256  if (l_getIndexFromFile(fname, &index)) {
257  L_ERROR("File %s has no recognizable type\n", procName, fname);
258  } else {
259  type = l_assoc[index].type;
260  L_INFO("File %s is type %s\n", procName, fname, type);
261  strcodeGenerate(strcode, fname, type);
262  }
263  }
264  strcodeFinalize(&strcode, outdir);
265  sarrayDestroy(&sa);
266  return 0;
267 }
268 
269 
288 l_ok
290  const char *filein,
291  const char *type)
292 {
293 char *strdata, *strfunc, *strdescr;
294 l_int32 itype;
295 
296  PROCNAME("strcodeGenerate");
297 
298  if (!strcode)
299  return ERROR_INT("strcode not defined", procName, 1);
300  if (!filein)
301  return ERROR_INT("filein not defined", procName, 1);
302  if (!type)
303  return ERROR_INT("type not defined", procName, 1);
304 
305  /* Get the index corresponding to type and validate */
306  if (l_getIndexFromType(type, &itype) == 1)
307  return ERROR_INT("data type unknown", procName, 1);
308 
309  /* Generate the encoded data string */
310  if ((strdata = l_genDataString(filein, strcode->ifunc)) == NULL)
311  return ERROR_INT("strdata not made", procName, 1);
312  sarrayAddString(strcode->data, strdata, L_INSERT);
313 
314  /* Generate the case data for the decoding function */
315  strfunc = l_genCaseString(strcode->ifunc, itype);
316  sarrayAddString(strcode->function, strfunc, L_INSERT);
317 
318  /* Generate row of table for function type selection */
319  strdescr = l_genDescrString(filein, strcode->ifunc, itype);
320  sarrayAddString(strcode->descr, strdescr, L_INSERT);
321 
322  strcode->n++;
323  strcode->ifunc++;
324  return 0;
325 }
326 
327 
335 l_int32
337  const char *outdir)
338 {
339 char buf[256];
340 char *filestr, *casestr, *descr, *datastr, *realoutdir;
341 l_int32 actstart, end, newstart, fileno, nbytes;
342 size_t size;
343 L_STRCODE *strcode;
344 SARRAY *sa1, *sa2, *sa3;
345 
346  PROCNAME("strcodeFinalize");
347 
348  lept_mkdir("lept/auto");
349 
350  if (!pstrcode || *pstrcode == NULL)
351  return ERROR_INT("No input data", procName, 1);
352  strcode = *pstrcode;
353  if (!outdir) {
354  L_INFO("no outdir specified; writing to /tmp/lept/auto\n", procName);
355  realoutdir = stringNew("/tmp/lept/auto");
356  } else {
357  realoutdir = stringNew(outdir);
358  }
359 
360  /* ------------------------------------------------------- */
361  /* Make the output autogen.*.c file */
362  /* ------------------------------------------------------- */
363 
364  /* Make array of textlines from TEMPLATE1 */
365  filestr = (char *)l_binaryRead(TEMPLATE1, &size);
366  sa1 = sarrayCreateLinesFromString(filestr, 1);
367  LEPT_FREE(filestr);
368  sa3 = sarrayCreate(0);
369 
370  /* Copyright notice */
371  sarrayParseRange(sa1, 0, &actstart, &end, &newstart, "--", 0);
372  sarrayAppendRange(sa3, sa1, actstart, end);
373 
374  /* File name comment */
375  fileno = strcode->fileno;
376  snprintf(buf, sizeof(buf), " * autogen.%d.c", fileno);
377  sarrayAddString(sa3, buf, L_COPY);
378 
379  /* More text */
380  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
381  sarrayAppendRange(sa3, sa1, actstart, end);
382 
383  /* Description of function types by index */
384  descr = sarrayToString(strcode->descr, 1);
385  descr[strlen(descr) - 1] = '\0';
386  sarrayAddString(sa3, descr, L_INSERT);
387 
388  /* Includes */
389  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
390  sarrayAppendRange(sa3, sa1, actstart, end);
391  snprintf(buf, sizeof(buf), "#include \"autogen.%d.h\"", fileno);
392  sarrayAddString(sa3, buf, L_COPY);
393 
394  /* Header for auto-generated deserializers */
395  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
396  sarrayAppendRange(sa3, sa1, actstart, end);
397 
398  /* Function name (as comment) */
399  snprintf(buf, sizeof(buf), " * l_autodecode_%d()", fileno);
400  sarrayAddString(sa3, buf, L_COPY);
401 
402  /* Input and return values */
403  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
404  sarrayAppendRange(sa3, sa1, actstart, end);
405 
406  /* Function name */
407  snprintf(buf, sizeof(buf), "l_autodecode_%d(l_int32 index)", fileno);
408  sarrayAddString(sa3, buf, L_COPY);
409 
410  /* Stack vars */
411  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
412  sarrayAppendRange(sa3, sa1, actstart, end);
413 
414  /* Declaration of nfunc on stack */
415  snprintf(buf, sizeof(buf), "l_int32 nfunc = %d;\n", strcode->n);
416  sarrayAddString(sa3, buf, L_COPY);
417 
418  /* Declaration of PROCNAME */
419  snprintf(buf, sizeof(buf), " PROCNAME(\"l_autodecode_%d\");", fileno);
420  sarrayAddString(sa3, buf, L_COPY);
421 
422  /* Test input variables */
423  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
424  sarrayAppendRange(sa3, sa1, actstart, end);
425 
426  /* Insert case string */
427  casestr = sarrayToString(strcode->function, 0);
428  casestr[strlen(casestr) - 1] = '\0';
429  sarrayAddString(sa3, casestr, L_INSERT);
430 
431  /* End of function */
432  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
433  sarrayAppendRange(sa3, sa1, actstart, end);
434 
435  /* Flatten to string and output to autogen*.c file */
436  filestr = sarrayToString(sa3, 1);
437  nbytes = strlen(filestr);
438  snprintf(buf, sizeof(buf), "%s/autogen.%d.c", realoutdir, fileno);
439  l_binaryWrite(buf, "w", filestr, nbytes);
440  LEPT_FREE(filestr);
441  sarrayDestroy(&sa1);
442  sarrayDestroy(&sa3);
443 
444  /* ------------------------------------------------------- */
445  /* Make the output autogen.*.h file */
446  /* ------------------------------------------------------- */
447 
448  /* Make array of textlines from TEMPLATE2 */
449  filestr = (char *)l_binaryRead(TEMPLATE2, &size);
450  sa2 = sarrayCreateLinesFromString(filestr, 1);
451  LEPT_FREE(filestr);
452  sa3 = sarrayCreate(0);
453 
454  /* Copyright notice */
455  sarrayParseRange(sa2, 0, &actstart, &end, &newstart, "--", 0);
456  sarrayAppendRange(sa3, sa2, actstart, end);
457 
458  /* File name comment */
459  snprintf(buf, sizeof(buf), " * autogen.%d.h", fileno);
460  sarrayAddString(sa3, buf, L_COPY);
461 
462  /* More text */
463  sarrayParseRange(sa2, newstart, &actstart, &end, &newstart, "--", 0);
464  sarrayAppendRange(sa3, sa2, actstart, end);
465 
466  /* Beginning header protection */
467  snprintf(buf, sizeof(buf), "#ifndef LEPTONICA_AUTOGEN_%d_H\n"
468  "#define LEPTONICA_AUTOGEN_%d_H",
469  fileno, fileno);
470  sarrayAddString(sa3, buf, L_COPY);
471 
472  /* Prototype header text */
473  sarrayParseRange(sa2, newstart, &actstart, &end, &newstart, "--", 0);
474  sarrayAppendRange(sa3, sa2, actstart, end);
475 
476  /* Prototype declaration */
477  snprintf(buf, sizeof(buf), "void *l_autodecode_%d(l_int32 index);", fileno);
478  sarrayAddString(sa3, buf, L_COPY);
479 
480  /* Prototype trailer text */
481  sarrayParseRange(sa2, newstart, &actstart, &end, &newstart, "--", 0);
482  sarrayAppendRange(sa3, sa2, actstart, end);
483 
484  /* Insert serialized data strings */
485  datastr = sarrayToString(strcode->data, 1);
486  datastr[strlen(datastr) - 1] = '\0';
487  sarrayAddString(sa3, datastr, L_INSERT);
488 
489  /* End header protection */
490  snprintf(buf, sizeof(buf), "#endif /* LEPTONICA_AUTOGEN_%d_H */", fileno);
491  sarrayAddString(sa3, buf, L_COPY);
492 
493  /* Flatten to string and output to autogen*.h file */
494  filestr = sarrayToString(sa3, 1);
495  nbytes = strlen(filestr);
496  snprintf(buf, sizeof(buf), "%s/autogen.%d.h", realoutdir, fileno);
497  l_binaryWrite(buf, "w", filestr, nbytes);
498  LEPT_FREE(filestr);
499  LEPT_FREE(realoutdir);
500  sarrayDestroy(&sa2);
501  sarrayDestroy(&sa3);
502 
503  /* Cleanup */
504  strcodeDestroy(pstrcode);
505  return 0;
506 }
507 
508 
524 l_int32
525 l_getStructStrFromFile(const char *filename,
526  l_int32 field,
527  char **pstr)
528 {
529 l_int32 index;
530 
531  PROCNAME("l_getStructStrFromFile");
532 
533  if (!pstr)
534  return ERROR_INT("&str not defined", procName, 1);
535  *pstr = NULL;
536  if (!filename)
537  return ERROR_INT("filename not defined", procName, 1);
538  if (field != L_STR_TYPE && field != L_STR_NAME &&
539  field != L_STR_READER && field != L_STR_MEMREADER)
540  return ERROR_INT("invalid field", procName, 1);
541 
542  if (l_getIndexFromFile(filename, &index))
543  return ERROR_INT("index not retrieved", procName, 1);
544  if (field == L_STR_TYPE)
545  *pstr = stringNew(l_assoc[index].type);
546  else if (field == L_STR_NAME)
547  *pstr = stringNew(l_assoc[index].structname);
548  else if (field == L_STR_READER)
549  *pstr = stringNew(l_assoc[index].reader);
550  else /* field == L_STR_MEMREADER */
551  *pstr = stringNew(l_assoc[index].memreader);
552  return 0;
553 }
554 
555 
556 /*---------------------------------------------------------------------*/
557 /* Static helpers */
558 /*---------------------------------------------------------------------*/
571 static l_int32
572 l_getIndexFromType(const char *type,
573  l_int32 *pindex)
574 {
575 l_int32 i, found;
576 
577  PROCNAME("l_getIndexFromType");
578 
579  if (!pindex)
580  return ERROR_INT("&index not defined", procName, 1);
581  *pindex = 0;
582  if (!type)
583  return ERROR_INT("type string not defined", procName, 1);
584 
585  found = 0;
586  for (i = 1; i <= l_ntypes; i++) {
587  if (strcmp(type, l_assoc[i].type) == 0) {
588  found = 1;
589  *pindex = i;
590  break;
591  }
592  }
593  return !found;
594 }
595 
596 
611 static l_int32
613  l_int32 *pindex)
614 {
615 l_int32 i, found;
616 
617  PROCNAME("l_getIndexFromStructname");
618 
619  if (!pindex)
620  return ERROR_INT("&index not defined", procName, 1);
621  *pindex = 0;
622  if (!sn)
623  return ERROR_INT("sn string not defined", procName, 1);
624 
625  found = 0;
626  for (i = 1; i <= l_ntypes; i++) {
627  if (strcmp(sn, l_assoc[i].structname) == 0) {
628  found = 1;
629  *pindex = i;
630  break;
631  }
632  }
633  return !found;
634 }
635 
636 
644 static l_int32
645 l_getIndexFromFile(const char *filename,
646  l_int32 *pindex)
647 {
648 char buf[256];
649 char *word;
650 FILE *fp;
651 l_int32 notfound, format;
652 SARRAY *sa;
653 
654  PROCNAME("l_getIndexFromFile");
655 
656  if (!pindex)
657  return ERROR_INT("&index not defined", procName, 1);
658  *pindex = 0;
659  if (!filename)
660  return ERROR_INT("filename not defined", procName, 1);
661 
662  /* Open the stream, read lines until you find one with more
663  * than a newline, and grab the first word. */
664  if ((fp = fopenReadStream(filename)) == NULL)
665  return ERROR_INT("stream not opened", procName, 1);
666  do {
667  if ((fgets(buf, sizeof(buf), fp)) == NULL) {
668  fclose(fp);
669  return ERROR_INT("fgets read fail", procName, 1);
670  }
671  } while (buf[0] == '\n');
672  fclose(fp);
673  sa = sarrayCreateWordsFromString(buf);
674  word = sarrayGetString(sa, 0, L_NOCOPY);
675 
676  /* Find the index associated with the word. If it is not
677  * found, test to see if the file is a compressed pix. */
678  notfound = l_getIndexFromStructname(word, pindex);
679  sarrayDestroy(&sa);
680  if (notfound) { /* maybe a Pix */
681  if (findFileFormat(filename, &format) == 0) {
682  l_getIndexFromStructname("Pix", pindex);
683  } else {
684  return ERROR_INT("no file type identified", procName, 1);
685  }
686  }
687 
688  return 0;
689 }
690 
691 
699 static char *
700 l_genDataString(const char *filein,
701  l_int32 ifunc)
702 {
703 char buf[80];
704 char *cdata1, *cdata2, *cdata3;
705 l_uint8 *data1, *data2;
706 l_int32 csize1, csize2;
707 size_t size1, size2;
708 SARRAY *sa;
709 
710  PROCNAME("l_genDataString");
711 
712  if (!filein)
713  return (char *)ERROR_PTR("filein not defined", procName, NULL);
714 
715  /* Read it in, gzip it, encode, and reformat. We gzip because some
716  * serialized data has a significant amount of ascii content. */
717  if ((data1 = l_binaryRead(filein, &size1)) == NULL)
718  return (char *)ERROR_PTR("bindata not returned", procName, NULL);
719  data2 = zlibCompress(data1, size1, &size2);
720  cdata1 = encodeBase64(data2, size2, &csize1);
721  cdata2 = reformatPacked64(cdata1, csize1, 4, 72, 1, &csize2);
722  LEPT_FREE(data1);
723  LEPT_FREE(data2);
724  LEPT_FREE(cdata1);
725 
726  /* Prepend the string declaration signature and put it together */
727  sa = sarrayCreate(3);
728  snprintf(buf, sizeof(buf), "static const char *l_strdata_%d =\n", ifunc);
729  sarrayAddString(sa, buf, L_COPY);
730  sarrayAddString(sa, cdata2, L_INSERT);
731  sarrayAddString(sa, ";\n", L_COPY);
732  cdata3 = sarrayToString(sa, 0);
733  sarrayDestroy(&sa);
734  return cdata3;
735 }
736 
737 
750 static char *
751 l_genCaseString(l_int32 ifunc,
752  l_int32 itype)
753 {
754 char buf[256];
755 char *code = NULL;
756 
757  snprintf(buf, sizeof(buf), " case %d:\n", ifunc);
758  stringJoinIP(&code, buf);
759  snprintf(buf, sizeof(buf),
760  " data1 = decodeBase64(l_strdata_%d, strlen(l_strdata_%d), "
761  "&size1);\n", ifunc, ifunc);
762  stringJoinIP(&code, buf);
763  stringJoinIP(&code,
764  " data2 = zlibUncompress(data1, size1, &size2);\n");
765  snprintf(buf, sizeof(buf),
766  " result = (void *)%s(data2, size2);\n",
767  l_assoc[itype].memreader);
768  stringJoinIP(&code, buf);
769  stringJoinIP(&code, " lept_free(data1);\n");
770  stringJoinIP(&code, " lept_free(data2);\n");
771  stringJoinIP(&code, " break;\n");
772  return code;
773 }
774 
775 
784 static char *
785 l_genDescrString(const char *filein,
786  l_int32 ifunc,
787  l_int32 itype)
788 {
789 char buf[256];
790 char *tail;
791 
792  PROCNAME("l_genDescrString");
793 
794  if (!filein)
795  return (char *)ERROR_PTR("filein not defined", procName, NULL);
796 
797  splitPathAtDirectory(filein, NULL, &tail);
798  snprintf(buf, sizeof(buf), " * %-2d %-10s %-14s %s",
799  ifunc, l_assoc[itype].type, l_assoc[itype].reader, tail);
800 
801  LEPT_FREE(tail);
802  return stringNew(buf);
803 }
l_uint8 * zlibCompress(l_uint8 *datain, size_t nin, size_t *pnout)
zlibCompress()
Definition: zlibmem.c:92
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
Definition: utils2.c:1944
char * sarrayToString(SARRAY *sa, l_int32 addnlflag)
sarrayToString()
Definition: sarray1.c:763
Definition: pix.h:717
l_ok strcodeCreateFromFile(const char *filein, l_int32 fileno, const char *outdir)
strcodeCreateFromFile()
Definition: stringcode.c:223
static l_int32 l_getIndexFromFile(const char *file, l_int32 *pindex)
l_getIndexFromFile()
Definition: stringcode.c:645
Definition: pix.h:716
char * stringNew(const char *src)
stringNew()
Definition: utils2.c:215
static char * l_genDataString(const char *filein, l_int32 ifunc)
l_genDataString()
Definition: stringcode.c:700
SARRAY * sarrayCreate(l_int32 n)
sarrayCreate()
Definition: sarray1.c:163
SARRAY * descr
Definition: stringcode.h:46
l_int32 strcodeFinalize(L_STRCODE **pstrcode, const char *outdir)
strcodeFinalize()
Definition: stringcode.c:336
static void strcodeDestroy(L_STRCODE **pstrcode)
strcodeDestroy()
Definition: stringcode.c:182
Definition: array.h:116
l_ok sarrayAppendRange(SARRAY *sa1, SARRAY *sa2, l_int32 start, l_int32 end)
sarrayAppendRange()
Definition: sarray1.c:920
l_int32 l_getStructStrFromFile(const char *filename, l_int32 field, char **pstr)
l_getStructStrFromFile()
Definition: stringcode.c:525
static const struct L_GenAssoc l_assoc[]
Definition: stringcode.c:107
l_ok l_binaryWrite(const char *filename, const char *operation, const void *data, size_t nbytes)
l_binaryWrite()
Definition: utils2.c:1429
l_uint8 * l_binaryRead(const char *filename, size_t *pnbytes)
l_binaryRead()
Definition: utils2.c:1212
static l_int32 l_getIndexFromType(const char *type, l_int32 *pindex)
l_getIndexFromType()
Definition: stringcode.c:572
l_ok sarrayAddString(SARRAY *sa, const char *string, l_int32 copyflag)
sarrayAddString()
Definition: sarray1.c:446
l_int32 ifunc
Definition: stringcode.h:43
l_ok stringJoinIP(char **psrc1, const char *src2)
stringJoinIP()
Definition: utils2.c:564
l_ok strcodeGenerate(L_STRCODE *strcode, const char *filein, const char *type)
strcodeGenerate()
Definition: stringcode.c:289
L_STRCODE * strcodeCreate(l_int32 fileno)
strcodeCreate()
Definition: stringcode.c:156
l_ok findFileFormat(const char *filename, l_int32 *pformat)
findFileFormat()
Definition: readfile.c:580
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
Definition: sarray1.c:681
l_int32 n
Definition: stringcode.h:47
l_int32 fileno
Definition: stringcode.h:42
static char * l_genCaseString(l_int32 ifunc, l_int32 itype)
l_genCaseString()
Definition: stringcode.c:751
SARRAY * sarrayCreateLinesFromString(const char *string, l_int32 blankflag)
sarrayCreateLinesFromString()
Definition: sarray1.c:276
l_ok splitPathAtDirectory(const char *pathname, char **pdir, char **ptail)
splitPathAtDirectory()
Definition: utils2.c:2540
FILE * fopenReadStream(const char *filename)
fopenReadStream()
Definition: utils2.c:1657
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
Definition: sarray1.c:621
SARRAY * function
Definition: stringcode.h:44
Definition: pix.h:718
static char * l_genDescrString(const char *filein, l_int32 ifunc, l_int32 itype)
l_genDescrString()
Definition: stringcode.c:785
static const l_int32 l_ntypes
Definition: stringcode.c:105
l_int32 sarrayParseRange(SARRAY *sa, l_int32 start, l_int32 *pactualstart, l_int32 *pend, l_int32 *pnewstart, const char *substr, l_int32 loc)
sarrayParseRange()
Definition: sarray1.c:1260
static l_int32 l_getIndexFromStructname(const char *sn, l_int32 *pindex)
l_getIndexFromStructname()
Definition: stringcode.c:612
SARRAY * sarrayCreateWordsFromString(const char *string)
sarrayCreateWordsFromString()
Definition: sarray1.c:226
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
Definition: sarray1.c:355
SARRAY * data
Definition: stringcode.h:45