Leptonica  1.73
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_int32
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_int32
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 
523 l_int32
524 l_getStructStrFromFile(const char *filename,
525  l_int32 field,
526  char **pstr)
527 {
528 l_int32 index;
529 
530  PROCNAME("l_getStructStrFromFile");
531 
532  if (!pstr)
533  return ERROR_INT("&str not defined", procName, 1);
534  *pstr = NULL;
535  if (!filename)
536  return ERROR_INT("filename not defined", procName, 1);
537  if (field != L_STR_TYPE && field != L_STR_NAME &&
538  field != L_STR_READER && field != L_STR_MEMREADER)
539  return ERROR_INT("invalid field", procName, 1);
540 
541  if (l_getIndexFromFile(filename, &index))
542  return ERROR_INT("index not retrieved", procName, 1);
543  if (field == L_STR_TYPE)
544  *pstr = stringNew(l_assoc[index].type);
545  else if (field == L_STR_NAME)
546  *pstr = stringNew(l_assoc[index].structname);
547  else if (field == L_STR_READER)
548  *pstr = stringNew(l_assoc[index].reader);
549  else /* field == L_STR_MEMREADER */
550  *pstr = stringNew(l_assoc[index].memreader);
551  return 0;
552 }
553 
554 
555 /*---------------------------------------------------------------------*/
556 /* Static helpers */
557 /*---------------------------------------------------------------------*/
570 static l_int32
571 l_getIndexFromType(const char *type,
572  l_int32 *pindex)
573 {
574 l_int32 i, found;
575 
576  PROCNAME("l_getIndexFromType");
577 
578  if (!pindex)
579  return ERROR_INT("&index not defined", procName, 1);
580  *pindex = 0;
581  if (!type)
582  return ERROR_INT("type string not defined", procName, 1);
583 
584  found = 0;
585  for (i = 1; i <= l_ntypes; i++) {
586  if (strcmp(type, l_assoc[i].type) == 0) {
587  found = 1;
588  *pindex = i;
589  break;
590  }
591  }
592  return !found;
593 }
594 
595 
610 static l_int32
612  l_int32 *pindex)
613 {
614 l_int32 i, found;
615 
616  PROCNAME("l_getIndexFromStructname");
617 
618  if (!pindex)
619  return ERROR_INT("&index not defined", procName, 1);
620  *pindex = 0;
621  if (!sn)
622  return ERROR_INT("sn string not defined", procName, 1);
623 
624  found = 0;
625  for (i = 1; i <= l_ntypes; i++) {
626  if (strcmp(sn, l_assoc[i].structname) == 0) {
627  found = 1;
628  *pindex = i;
629  break;
630  }
631  }
632  return !found;
633 }
634 
635 
643 static l_int32
644 l_getIndexFromFile(const char *filename,
645  l_int32 *pindex)
646 {
647 char buf[256];
648 char *word;
649 FILE *fp;
650 l_int32 notfound, format;
651 SARRAY *sa;
652 
653  PROCNAME("l_getIndexFromFile");
654 
655  if (!pindex)
656  return ERROR_INT("&index not defined", procName, 1);
657  *pindex = 0;
658  if (!filename)
659  return ERROR_INT("filename not defined", procName, 1);
660 
661  /* Open the stream, read lines until you find one with more
662  * than a newline, and grab the first word. */
663  if ((fp = fopenReadStream(filename)) == NULL)
664  return ERROR_INT("stream not opened", procName, 1);
665  do {
666  if ((fgets(buf, sizeof(buf), fp)) == NULL) {
667  fclose(fp);
668  return ERROR_INT("fgets read fail", procName, 1);
669  }
670  } while (buf[0] == '\n');
671  fclose(fp);
672  sa = sarrayCreateWordsFromString(buf);
673  word = sarrayGetString(sa, 0, L_NOCOPY);
674 
675  /* Find the index associated with the word. If it is not
676  * found, test to see if the file is a compressed pix. */
677  notfound = l_getIndexFromStructname(word, pindex);
678  sarrayDestroy(&sa);
679  if (notfound) { /* maybe a Pix */
680  if (findFileFormat(filename, &format) == 0) {
681  l_getIndexFromStructname("Pix", pindex);
682  } else {
683  return ERROR_INT("no file type identified", procName, 1);
684  }
685  }
686 
687  return 0;
688 }
689 
690 
698 static char *
699 l_genDataString(const char *filein,
700  l_int32 ifunc)
701 {
702 char buf[80];
703 char *cdata1, *cdata2, *cdata3;
704 l_uint8 *data1, *data2;
705 l_int32 csize1, csize2;
706 size_t size1, size2;
707 SARRAY *sa;
708 
709  PROCNAME("l_genDataString");
710 
711  if (!filein)
712  return (char *)ERROR_PTR("filein not defined", procName, NULL);
713 
714  /* Read it in, gzip it, encode, and reformat. We gzip because some
715  * serialized data has a significant amount of ascii content. */
716  if ((data1 = l_binaryRead(filein, &size1)) == NULL)
717  return (char *)ERROR_PTR("bindata not returned", procName, NULL);
718  data2 = zlibCompress(data1, size1, &size2);
719  cdata1 = encodeBase64(data2, size2, &csize1);
720  cdata2 = reformatPacked64(cdata1, csize1, 4, 72, 1, &csize2);
721  LEPT_FREE(data1);
722  LEPT_FREE(data2);
723  LEPT_FREE(cdata1);
724 
725  /* Prepend the string declaration signature and put it together */
726  sa = sarrayCreate(3);
727  snprintf(buf, sizeof(buf), "static const char *l_strdata_%d =\n", ifunc);
728  sarrayAddString(sa, buf, L_COPY);
729  sarrayAddString(sa, cdata2, L_INSERT);
730  sarrayAddString(sa, (char *)";\n", L_COPY);
731  cdata3 = sarrayToString(sa, 0);
732  sarrayDestroy(&sa);
733  return cdata3;
734 }
735 
736 
749 static char *
750 l_genCaseString(l_int32 ifunc,
751  l_int32 itype)
752 {
753 char buf[256];
754 char *code = NULL;
755 
756  snprintf(buf, sizeof(buf), " case %d:\n", ifunc);
757  stringJoinIP(&code, buf);
758  snprintf(buf, sizeof(buf),
759  " data1 = decodeBase64(l_strdata_%d, strlen(l_strdata_%d), "
760  "&size1);\n", ifunc, ifunc);
761  stringJoinIP(&code, buf);
762  stringJoinIP(&code,
763  " data2 = zlibUncompress(data1, size1, &size2);\n");
764  snprintf(buf, sizeof(buf),
765  " result = (void *)%s(data2, size2);\n",
766  l_assoc[itype].memreader);
767  stringJoinIP(&code, buf);
768  stringJoinIP(&code, " lept_free(data1);\n");
769  stringJoinIP(&code, " lept_free(data2);\n");
770  stringJoinIP(&code, " break;\n");
771  return code;
772 }
773 
774 
783 static char *
784 l_genDescrString(const char *filein,
785  l_int32 ifunc,
786  l_int32 itype)
787 {
788 char buf[256];
789 char *tail;
790 
791  PROCNAME("l_genDescrString");
792 
793  if (!filein)
794  return (char *)ERROR_PTR("filein not defined", procName, NULL);
795 
796  splitPathAtDirectory(filein, NULL, &tail);
797  snprintf(buf, sizeof(buf), " * %-2d %-10s %-14s %s",
798  ifunc, l_assoc[itype].type, l_assoc[itype].reader, tail);
799 
800  LEPT_FREE(tail);
801  return stringNew(buf);
802 }
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:1880
char * sarrayToString(SARRAY *sa, l_int32 addnlflag)
sarrayToString()
Definition: sarray1.c:757
static l_int32 l_getIndexFromFile(const char *file, l_int32 *pindex)
l_getIndexFromFile()
Definition: stringcode.c:644
Definition: pix.h:704
char * stringNew(const char *src)
stringNew()
Definition: utils2.c:202
l_int32 splitPathAtDirectory(const char *pathname, char **pdir, char **ptail)
splitPathAtDirectory()
Definition: utils2.c:2419
static char * l_genDataString(const char *filein, l_int32 ifunc)
l_genDataString()
Definition: stringcode.c:699
SARRAY * sarrayCreate(l_int32 n)
sarrayCreate()
Definition: sarray1.c:157
SARRAY * descr
Definition: stringcode.h:46
l_int32 sarrayAppendRange(SARRAY *sa1, SARRAY *sa2, l_int32 start, l_int32 end)
sarrayAppendRange()
Definition: sarray1.c:914
l_int32 strcodeFinalize(L_STRCODE **pstrcode, const char *outdir)
strcodeFinalize()
Definition: stringcode.c:336
l_int32 findFileFormat(const char *filename, l_int32 *pformat)
findFileFormat()
Definition: readfile.c:568
static void strcodeDestroy(L_STRCODE **pstrcode)
strcodeDestroy()
Definition: stringcode.c:182
Definition: array.h:116
static const struct L_GenAssoc l_assoc[]
Definition: stringcode.c:107
l_int32 strcodeGenerate(L_STRCODE *strcode, const char *filein, const char *type)
strcodeGenerate()
Definition: stringcode.c:289
l_uint8 * l_binaryRead(const char *filename, size_t *pnbytes)
l_binaryRead()
Definition: utils2.c:1154
l_int32 stringJoinIP(char **psrc1, const char *src2)
stringJoinIP()
Definition: utils2.c:506
static const l_int32 L_INSERT
Definition: pix.h:710
static l_int32 l_getIndexFromType(const char *type, l_int32 *pindex)
l_getStructStrFromFile()
Definition: stringcode.c:571
l_int32 ifunc
Definition: stringcode.h:43
L_STRCODE * strcodeCreate(l_int32 fileno)
strcodeCreate()
Definition: stringcode.c:156
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
Definition: sarray1.c:675
l_int32 sarrayAddString(SARRAY *sa, char *string, l_int32 copyflag)
sarrayAddString()
Definition: sarray1.c:439
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:750
SARRAY * sarrayCreateLinesFromString(const char *string, l_int32 blankflag)
sarrayCreateLinesFromString()
Definition: sarray1.c:270
FILE * fopenReadStream(const char *filename)
fopenReadStream()
Definition: utils2.c:1593
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
Definition: sarray1.c:615
SARRAY * function
Definition: stringcode.h:44
l_int32 l_binaryWrite(const char *filename, const char *operation, void *data, size_t nbytes)
l_binaryWrite()
Definition: utils2.c:1367
Definition: pix.h:705
static char * l_genDescrString(const char *filein, l_int32 ifunc, l_int32 itype)
l_genDescrString()
Definition: stringcode.c:784
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:1253
l_int32 strcodeCreateFromFile(const char *filein, l_int32 fileno, const char *outdir)
strcodeCreateFromFile()
Definition: stringcode.c:223
static l_int32 l_getIndexFromStructname(const char *sn, l_int32 *pindex)
l_getIndexFromStructname()
Definition: stringcode.c:611
SARRAY * sarrayCreateWordsFromString(const char *string)
sarrayCreateWordsFromString()
Definition: sarray1.c:220
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
Definition: sarray1.c:349
SARRAY * data
Definition: stringcode.h:45