Leptonica  1.83.1
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 #ifdef HAVE_CONFIG_H
88 #include <config_auto.h>
89 #endif /* HAVE_CONFIG_H */
90 
91 #include <string.h>
92 #include "allheaders.h"
93 #include "stringcode.h"
94 
95 #define TEMPLATE1 "stringtemplate1.txt" /* for assembling autogen.*.c */
96 #define TEMPLATE2 "stringtemplate2.txt" /* for assembling autogen.*.h */
97 
99 struct L_GenAssoc
100 {
101  l_int32 index;
102  char type[16]; /* e.g., "PIXA" */
103  char structname[16]; /* e.g., "Pixa" */
104  char reader[16]; /* e.g., "pixaRead" */
105  char memreader[20]; /* e.g., "pixaReadMem" */
106 };
107 
109 static const l_int32 l_ntypes = 19;
111 static const struct L_GenAssoc l_assoc[] = {
112  {0, "INVALID", "invalid", "invalid", "invalid" },
113  {1, "BOXA", "Boxa", "boxaRead", "boxaReadMem" },
114  {2, "BOXAA", "Boxaa", "boxaaRead", "boxaaReadMem" },
115  {3, "L_DEWARP", "Dewarp", "dewarpRead", "dewarpReadMem" },
116  {4, "L_DEWARPA", "Dewarpa", "dewarpaRead", "dewarpaReadMem" },
117  {5, "L_DNA", "L_Dna", "l_dnaRead", "l_dnaReadMem" },
118  {6, "L_DNAA", "L_Dnaa", "l_dnaaRead", "l_dnaaReadMem" },
119  {7, "DPIX", "DPix", "dpixRead", "dpixReadMem" },
120  {8, "FPIX", "FPix", "fpixRead", "fpixReadMem" },
121  {9, "NUMA", "Numa", "numaRead", "numaReadMem" },
122  {10, "NUMAA", "Numaa", "numaaRead", "numaaReadMem" },
123  {11, "PIX", "Pix", "pixRead", "pixReadMem" },
124  {12, "PIXA", "Pixa", "pixaRead", "pixaReadMem" },
125  {13, "PIXAA", "Pixaa", "pixaaRead", "pixaaReadMem" },
126  {14, "PIXACOMP", "Pixacomp", "pixacompRead", "pixacompReadMem" },
127  {15, "PIXCMAP", "Pixcmap", "pixcmapRead", "pixcmapReadMem" },
128  {16, "PTA", "Pta", "ptaRead", "ptaReadMem" },
129  {17, "PTAA", "Ptaa", "ptaaRead", "ptaaReadMem" },
130  {18, "RECOG", "Recog", "recogRead", "recogReadMem" },
131  {19, "SARRAY", "Sarray", "sarrayRead", "sarrayReadMem" }
132 };
133 
134 static l_int32 l_getIndexFromType(const char *type, l_int32 *pindex);
135 static l_int32 l_getIndexFromStructname(const char *sn, l_int32 *pindex);
136 static l_int32 l_getIndexFromFile(const char *file, l_int32 *pindex);
137 static char *l_genDataString(const char *filein, l_int32 ifunc);
138 static char *l_genCaseString(l_int32 ifunc, l_int32 itype);
139 static char *l_genDescrString(const char *filein, l_int32 ifunc, l_int32 itype);
140 
141 /*---------------------------------------------------------------------*/
142 /* Stringcode functions */
143 /*---------------------------------------------------------------------*/
158 L_STRCODE *
159 strcodeCreate(l_int32 fileno)
160 {
161 L_STRCODE *strcode;
162 
163  lept_mkdir("lept/auto");
164 
165  if ((strcode = (L_STRCODE *)LEPT_CALLOC(1, sizeof(L_STRCODE))) == NULL)
166  return (L_STRCODE *)ERROR_PTR("strcode not made", __func__, NULL);
167 
168  strcode->fileno = fileno;
169  strcode->function = sarrayCreate(0);
170  strcode->data = sarrayCreate(0);
171  strcode->descr = sarrayCreate(0);
172  return strcode;
173 }
174 
175 
182 static void
184 {
185 L_STRCODE *strcode;
186 
187  if (pstrcode == NULL) {
188  L_WARNING("ptr address is null!\n", __func__);
189  return;
190  }
191 
192  if ((strcode = *pstrcode) == NULL)
193  return;
194 
195  sarrayDestroy(&strcode->function);
196  sarrayDestroy(&strcode->data);
197  sarrayDestroy(&strcode->descr);
198  LEPT_FREE(strcode);
199  *pstrcode = NULL;
200 }
201 
202 
220 l_ok
221 strcodeCreateFromFile(const char *filein,
222  l_int32 fileno,
223  const char *outdir)
224 {
225 char *fname;
226 const char *type;
227 l_uint8 *data;
228 size_t nbytes;
229 l_int32 i, n, index;
230 SARRAY *sa;
231 L_STRCODE *strcode;
232 
233  if (!filein)
234  return ERROR_INT("filein not defined", __func__, 1);
235 
236  if ((data = l_binaryRead(filein, &nbytes)) == NULL)
237  return ERROR_INT("data not read from file", __func__, 1);
238  sa = sarrayCreateLinesFromString((char *)data, 0);
239  LEPT_FREE(data);
240  if (!sa)
241  return ERROR_INT("sa not made", __func__, 1);
242  if ((n = sarrayGetCount(sa)) == 0) {
243  sarrayDestroy(&sa);
244  return ERROR_INT("no filenames in the file", __func__, 1);
245  }
246 
247  strcode = strcodeCreate(fileno);
248 
249  for (i = 0; i < n; i++) {
250  fname = sarrayGetString(sa, i, L_NOCOPY);
251  if (fname[0] == '#') continue;
252  if (l_getIndexFromFile(fname, &index)) {
253  L_ERROR("File %s has no recognizable type\n", __func__, fname);
254  } else {
255  type = l_assoc[index].type;
256  L_INFO("File %s is type %s\n", __func__, fname, type);
257  strcodeGenerate(strcode, fname, type);
258  }
259  }
260  strcodeFinalize(&strcode, outdir);
261  sarrayDestroy(&sa);
262  return 0;
263 }
264 
265 
284 l_ok
286  const char *filein,
287  const char *type)
288 {
289 char *strdata, *strfunc, *strdescr;
290 l_int32 itype;
291 
292  if (!strcode)
293  return ERROR_INT("strcode not defined", __func__, 1);
294  if (!filein)
295  return ERROR_INT("filein not defined", __func__, 1);
296  if (!type)
297  return ERROR_INT("type not defined", __func__, 1);
298 
299  /* Get the index corresponding to type and validate */
300  if (l_getIndexFromType(type, &itype) == 1)
301  return ERROR_INT("data type unknown", __func__, 1);
302 
303  /* Generate the encoded data string */
304  if ((strdata = l_genDataString(filein, strcode->ifunc)) == NULL)
305  return ERROR_INT("strdata not made", __func__, 1);
306  sarrayAddString(strcode->data, strdata, L_INSERT);
307 
308  /* Generate the case data for the decoding function */
309  strfunc = l_genCaseString(strcode->ifunc, itype);
310  sarrayAddString(strcode->function, strfunc, L_INSERT);
311 
312  /* Generate row of table for function type selection */
313  strdescr = l_genDescrString(filein, strcode->ifunc, itype);
314  sarrayAddString(strcode->descr, strdescr, L_INSERT);
315 
316  strcode->n++;
317  strcode->ifunc++;
318  return 0;
319 }
320 
321 
330 l_int32
332  const char *outdir)
333 {
334 char buf[256];
335 char *filestr, *casestr, *descr, *datastr, *realoutdir;
336 l_int32 actstart, end, newstart, fileno, nbytes;
337 size_t size;
338 L_STRCODE *strcode;
339 SARRAY *sa1, *sa2, *sa3;
340 
341  lept_mkdir("lept/auto");
342 
343  if (!pstrcode || *pstrcode == NULL)
344  return ERROR_INT("No input data", __func__, 1);
345  strcode = *pstrcode;
346  if (!outdir) {
347  L_INFO("no outdir specified; writing to /tmp/lept/auto\n", __func__);
348  realoutdir = stringNew("/tmp/lept/auto");
349  } else {
350  realoutdir = stringNew(outdir);
351  }
352 
353  /* ------------------------------------------------------- */
354  /* Make the output autogen.*.c file */
355  /* ------------------------------------------------------- */
356 
357  /* Make array of textlines from TEMPLATE1 */
358  filestr = (char *)l_binaryRead(TEMPLATE1, &size);
359  sa1 = sarrayCreateLinesFromString(filestr, 1);
360  LEPT_FREE(filestr);
361  sa3 = sarrayCreate(0);
362 
363  /* Copyright notice */
364  sarrayParseRange(sa1, 0, &actstart, &end, &newstart, "--", 0);
365  sarrayAppendRange(sa3, sa1, actstart, end);
366 
367  /* File name comment */
368  fileno = strcode->fileno;
369  snprintf(buf, sizeof(buf), " * autogen.%d.c", fileno);
370  sarrayAddString(sa3, buf, L_COPY);
371 
372  /* More text */
373  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
374  sarrayAppendRange(sa3, sa1, actstart, end);
375 
376  /* Description of function types by index */
377  descr = sarrayToString(strcode->descr, 1);
378  descr[strlen(descr) - 1] = '\0';
379  sarrayAddString(sa3, descr, L_INSERT);
380 
381  /* Includes */
382  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
383  sarrayAppendRange(sa3, sa1, actstart, end);
384  snprintf(buf, sizeof(buf), "#include \"autogen.%d.h\"", fileno);
385  sarrayAddString(sa3, buf, L_COPY);
386 
387  /* Header for auto-generated deserializers */
388  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
389  sarrayAppendRange(sa3, sa1, actstart, end);
390 
391  /* Function name (as comment) */
392  snprintf(buf, sizeof(buf), " * \\brief l_autodecode_%d()", fileno);
393  sarrayAddString(sa3, buf, L_COPY);
394 
395  /* Input and return values */
396  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
397  sarrayAppendRange(sa3, sa1, actstart, end);
398 
399  /* Function name */
400  snprintf(buf, sizeof(buf), "l_autodecode_%d(l_int32 index)", fileno);
401  sarrayAddString(sa3, buf, L_COPY);
402 
403  /* Stack vars */
404  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
405  sarrayAppendRange(sa3, sa1, actstart, end);
406 
407  /* Declaration of nfunc on stack */
408  snprintf(buf, sizeof(buf), "l_int32 nfunc = %d;\n", strcode->n);
409  sarrayAddString(sa3, buf, L_COPY);
410 
411  /* Declaration of PROCNAME */
412  snprintf(buf, sizeof(buf), " PROCNAME(\"l_autodecode_%d\");", fileno);
413  sarrayAddString(sa3, buf, L_COPY);
414 
415  /* Test input variables */
416  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
417  sarrayAppendRange(sa3, sa1, actstart, end);
418 
419  /* Insert case string */
420  casestr = sarrayToString(strcode->function, 0);
421  casestr[strlen(casestr) - 1] = '\0';
422  sarrayAddString(sa3, casestr, L_INSERT);
423 
424  /* End of function */
425  sarrayParseRange(sa1, newstart, &actstart, &end, &newstart, "--", 0);
426  sarrayAppendRange(sa3, sa1, actstart, end);
427 
428  /* Flatten to string and output to autogen*.c file */
429  filestr = sarrayToString(sa3, 1);
430  nbytes = strlen(filestr);
431  snprintf(buf, sizeof(buf), "%s/autogen.%d.c", realoutdir, fileno);
432  l_binaryWrite(buf, "w", filestr, nbytes);
433  LEPT_FREE(filestr);
434  sarrayDestroy(&sa1);
435  sarrayDestroy(&sa3);
436 
437  /* ------------------------------------------------------- */
438  /* Make the output autogen.*.h file */
439  /* ------------------------------------------------------- */
440 
441  /* Make array of textlines from TEMPLATE2 */
442  filestr = (char *)l_binaryRead(TEMPLATE2, &size);
443  sa2 = sarrayCreateLinesFromString(filestr, 1);
444  LEPT_FREE(filestr);
445  sa3 = sarrayCreate(0);
446 
447  /* Copyright notice */
448  sarrayParseRange(sa2, 0, &actstart, &end, &newstart, "--", 0);
449  sarrayAppendRange(sa3, sa2, actstart, end);
450 
451  /* File name comment */
452  snprintf(buf, sizeof(buf), " * autogen.%d.h", fileno);
453  sarrayAddString(sa3, buf, L_COPY);
454 
455  /* More text */
456  sarrayParseRange(sa2, newstart, &actstart, &end, &newstart, "--", 0);
457  sarrayAppendRange(sa3, sa2, actstart, end);
458 
459  /* Beginning header protection */
460  snprintf(buf, sizeof(buf), "#ifndef LEPTONICA_AUTOGEN_%d_H\n"
461  "#define LEPTONICA_AUTOGEN_%d_H",
462  fileno, fileno);
463  sarrayAddString(sa3, buf, L_COPY);
464 
465  /* Prototype header text */
466  sarrayParseRange(sa2, newstart, &actstart, &end, &newstart, "--", 0);
467  sarrayAppendRange(sa3, sa2, actstart, end);
468 
469  /* Prototype declaration */
470  snprintf(buf, sizeof(buf), "void *l_autodecode_%d(l_int32 index);", fileno);
471  sarrayAddString(sa3, buf, L_COPY);
472 
473  /* Prototype trailer text */
474  sarrayParseRange(sa2, newstart, &actstart, &end, &newstart, "--", 0);
475  sarrayAppendRange(sa3, sa2, actstart, end);
476 
477  /* Insert serialized data strings */
478  datastr = sarrayToString(strcode->data, 1);
479  datastr[strlen(datastr) - 1] = '\0';
480  sarrayAddString(sa3, datastr, L_INSERT);
481 
482  /* End header protection */
483  snprintf(buf, sizeof(buf), "#endif /* LEPTONICA_AUTOGEN_%d_H */", fileno);
484  sarrayAddString(sa3, buf, L_COPY);
485 
486  /* Flatten to string and output to autogen*.h file */
487  filestr = sarrayToString(sa3, 1);
488  nbytes = strlen(filestr);
489  snprintf(buf, sizeof(buf), "%s/autogen.%d.h", realoutdir, fileno);
490  l_binaryWrite(buf, "w", filestr, nbytes);
491  LEPT_FREE(filestr);
492  LEPT_FREE(realoutdir);
493  sarrayDestroy(&sa2);
494  sarrayDestroy(&sa3);
495 
496  /* Cleanup */
497  strcodeDestroy(pstrcode);
498  return 0;
499 }
500 
501 
517 l_int32
518 l_getStructStrFromFile(const char *filename,
519  l_int32 field,
520  char **pstr)
521 {
522 l_int32 index;
523 
524  if (!pstr)
525  return ERROR_INT("&str not defined", __func__, 1);
526  *pstr = NULL;
527  if (!filename)
528  return ERROR_INT("filename not defined", __func__, 1);
529  if (field != L_STR_TYPE && field != L_STR_NAME &&
530  field != L_STR_READER && field != L_STR_MEMREADER)
531  return ERROR_INT("invalid field", __func__, 1);
532 
533  if (l_getIndexFromFile(filename, &index))
534  return ERROR_INT("index not retrieved", __func__, 1);
535  if (field == L_STR_TYPE)
536  *pstr = stringNew(l_assoc[index].type);
537  else if (field == L_STR_NAME)
538  *pstr = stringNew(l_assoc[index].structname);
539  else if (field == L_STR_READER)
540  *pstr = stringNew(l_assoc[index].reader);
541  else /* field == L_STR_MEMREADER */
542  *pstr = stringNew(l_assoc[index].memreader);
543  return 0;
544 }
545 
546 
547 /*---------------------------------------------------------------------*/
548 /* Static helpers */
549 /*---------------------------------------------------------------------*/
562 static l_int32
563 l_getIndexFromType(const char *type,
564  l_int32 *pindex)
565 {
566 l_int32 i, found;
567 
568  if (!pindex)
569  return ERROR_INT("&index not defined", __func__, 1);
570  *pindex = 0;
571  if (!type)
572  return ERROR_INT("type string not defined", __func__, 1);
573 
574  found = 0;
575  for (i = 1; i <= l_ntypes; i++) {
576  if (strcmp(type, l_assoc[i].type) == 0) {
577  found = 1;
578  *pindex = i;
579  break;
580  }
581  }
582  return !found;
583 }
584 
585 
600 static l_int32
602  l_int32 *pindex)
603 {
604 l_int32 i, found;
605 
606  if (!pindex)
607  return ERROR_INT("&index not defined", __func__, 1);
608  *pindex = 0;
609  if (!sn)
610  return ERROR_INT("sn string not defined", __func__, 1);
611 
612  found = 0;
613  for (i = 1; i <= l_ntypes; i++) {
614  if (strcmp(sn, l_assoc[i].structname) == 0) {
615  found = 1;
616  *pindex = i;
617  break;
618  }
619  }
620  return !found;
621 }
622 
623 
631 static l_int32
632 l_getIndexFromFile(const char *filename,
633  l_int32 *pindex)
634 {
635 char buf[256];
636 char *word;
637 FILE *fp;
638 l_int32 notfound, format;
639 SARRAY *sa;
640 
641  if (!pindex)
642  return ERROR_INT("&index not defined", __func__, 1);
643  *pindex = 0;
644  if (!filename)
645  return ERROR_INT("filename not defined", __func__, 1);
646 
647  /* Open the stream, read lines until you find one with more
648  * than a newline, and grab the first word. */
649  if ((fp = fopenReadStream(filename)) == NULL)
650  return ERROR_INT("stream not opened", __func__, 1);
651  do {
652  if ((fgets(buf, sizeof(buf), fp)) == NULL) {
653  fclose(fp);
654  return ERROR_INT("fgets read fail", __func__, 1);
655  }
656  } while (buf[0] == '\n');
657  fclose(fp);
658  sa = sarrayCreateWordsFromString(buf);
659  word = sarrayGetString(sa, 0, L_NOCOPY);
660 
661  /* Find the index associated with the word. If it is not
662  * found, test to see if the file is a compressed pix. */
663  notfound = l_getIndexFromStructname(word, pindex);
664  sarrayDestroy(&sa);
665  if (notfound) { /* maybe a Pix */
666  if (findFileFormat(filename, &format) == 0) {
667  l_getIndexFromStructname("Pix", pindex);
668  } else {
669  return ERROR_INT("no file type identified", __func__, 1);
670  }
671  }
672 
673  return 0;
674 }
675 
676 
684 static char *
685 l_genDataString(const char *filein,
686  l_int32 ifunc)
687 {
688 char buf[80];
689 char *cdata1, *cdata2, *cdata3;
690 l_uint8 *data1, *data2;
691 l_int32 csize1, csize2;
692 size_t size1, size2;
693 SARRAY *sa;
694 
695  if (!filein)
696  return (char *)ERROR_PTR("filein not defined", __func__, NULL);
697 
698  /* Read it in, gzip it, encode, and reformat. We gzip because some
699  * serialized data has a significant amount of ascii content. */
700  if ((data1 = l_binaryRead(filein, &size1)) == NULL)
701  return (char *)ERROR_PTR("bindata not returned", __func__, NULL);
702  data2 = zlibCompress(data1, size1, &size2);
703  cdata1 = encodeBase64(data2, size2, &csize1);
704  cdata2 = reformatPacked64(cdata1, csize1, 4, 72, 1, &csize2);
705  LEPT_FREE(data1);
706  LEPT_FREE(data2);
707  LEPT_FREE(cdata1);
708 
709  /* Prepend the string declaration signature and put it together */
710  sa = sarrayCreate(3);
711  snprintf(buf, sizeof(buf), "static const char *l_strdata_%d =\n", ifunc);
712  sarrayAddString(sa, buf, L_COPY);
713  sarrayAddString(sa, cdata2, L_INSERT);
714  sarrayAddString(sa, ";\n", L_COPY);
715  cdata3 = sarrayToString(sa, 0);
716  sarrayDestroy(&sa);
717  return cdata3;
718 }
719 
720 
733 static char *
734 l_genCaseString(l_int32 ifunc,
735  l_int32 itype)
736 {
737 char buf[256];
738 char *code = NULL;
739 
740  snprintf(buf, sizeof(buf), " case %d:\n", ifunc);
741  stringJoinIP(&code, buf);
742  snprintf(buf, sizeof(buf),
743  " data1 = decodeBase64(l_strdata_%d, strlen(l_strdata_%d), "
744  "&size1);\n", ifunc, ifunc);
745  stringJoinIP(&code, buf);
746  stringJoinIP(&code,
747  " data2 = zlibUncompress(data1, size1, &size2);\n");
748  snprintf(buf, sizeof(buf),
749  " result = (void *)%s(data2, size2);\n",
750  l_assoc[itype].memreader);
751  stringJoinIP(&code, buf);
752  stringJoinIP(&code, " lept_free(data1);\n");
753  stringJoinIP(&code, " lept_free(data2);\n");
754  stringJoinIP(&code, " break;\n");
755  return code;
756 }
757 
758 
767 static char *
768 l_genDescrString(const char *filein,
769  l_int32 ifunc,
770  l_int32 itype)
771 {
772 char buf[256];
773 char *tail;
774 
775  if (!filein)
776  return (char *)ERROR_PTR("filein not defined", __func__, NULL);
777 
778  splitPathAtDirectory(filein, NULL, &tail);
779  snprintf(buf, sizeof(buf), " * %-2d %-10s %-14s %s",
780  ifunc, l_assoc[itype].type, l_assoc[itype].reader, tail);
781 
782  LEPT_FREE(tail);
783  return stringNew(buf);
784 }
@ L_COPY
Definition: pix.h:505
@ L_NOCOPY
Definition: pix.h:503
@ L_INSERT
Definition: pix.h:504
l_ok findFileFormat(const char *filename, l_int32 *pformat)
findFileFormat()
Definition: readfile.c:570
SARRAY * sarrayCreate(l_int32 n)
sarrayCreate()
Definition: sarray1.c:169
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
Definition: sarray1.c:673
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
Definition: sarray1.c:617
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
Definition: sarray1.c:353
SARRAY * sarrayCreateWordsFromString(const char *string)
sarrayCreateWordsFromString()
Definition: sarray1.c:228
SARRAY * sarrayCreateLinesFromString(const char *string, l_int32 blankflag)
sarrayCreateLinesFromString()
Definition: sarray1.c:276
l_ok sarrayAddString(SARRAY *sa, const char *string, l_int32 copyflag)
sarrayAddString()
Definition: sarray1.c:435
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:1267
char * sarrayToString(SARRAY *sa, l_int32 addnlflag)
sarrayToString()
Definition: sarray1.c:716
l_ok sarrayAppendRange(SARRAY *sa1, SARRAY *sa2, l_int32 start, l_int32 end)
sarrayAppendRange()
Definition: sarray1.c:935
static l_int32 l_getIndexFromType(const char *type, l_int32 *pindex)
l_getIndexFromType()
Definition: stringcode.c:563
static l_int32 l_getIndexFromFile(const char *file, l_int32 *pindex)
l_getIndexFromFile()
Definition: stringcode.c:632
static char * l_genCaseString(l_int32 ifunc, l_int32 itype)
l_genCaseString()
Definition: stringcode.c:734
l_ok strcodeGenerate(L_STRCODE *strcode, const char *filein, const char *type)
strcodeGenerate()
Definition: stringcode.c:285
static void strcodeDestroy(L_STRCODE **pstrcode)
strcodeDestroy()
Definition: stringcode.c:183
static char * l_genDataString(const char *filein, l_int32 ifunc)
l_genDataString()
Definition: stringcode.c:685
static const struct L_GenAssoc l_assoc[]
Definition: stringcode.c:111
static l_int32 l_getIndexFromStructname(const char *sn, l_int32 *pindex)
l_getIndexFromStructname()
Definition: stringcode.c:601
L_STRCODE * strcodeCreate(l_int32 fileno)
strcodeCreate()
Definition: stringcode.c:159
l_int32 strcodeFinalize(L_STRCODE **pstrcode, const char *outdir)
strcodeFinalize()
Definition: stringcode.c:331
l_ok strcodeCreateFromFile(const char *filein, l_int32 fileno, const char *outdir)
strcodeCreateFromFile()
Definition: stringcode.c:221
l_int32 l_getStructStrFromFile(const char *filename, l_int32 field, char **pstr)
l_getStructStrFromFile()
Definition: stringcode.c:518
static const l_int32 l_ntypes
Definition: stringcode.c:109
static char * l_genDescrString(const char *filein, l_int32 ifunc, l_int32 itype)
l_genDescrString()
Definition: stringcode.c:768
@ L_STR_TYPE
Definition: stringcode.h:55
@ L_STR_READER
Definition: stringcode.h:57
@ L_STR_MEMREADER
Definition: stringcode.h:58
@ L_STR_NAME
Definition: stringcode.h:56
SARRAY * data
Definition: stringcode.h:45
l_int32 ifunc
Definition: stringcode.h:43
l_int32 fileno
Definition: stringcode.h:42
l_int32 n
Definition: stringcode.h:47
SARRAY * function
Definition: stringcode.h:44
SARRAY * descr
Definition: stringcode.h:46
char * stringNew(const char *src)
stringNew()
Definition: utils2.c:223
l_ok stringJoinIP(char **psrc1, const char *src2)
stringJoinIP()
Definition: utils2.c:559
l_ok splitPathAtDirectory(const char *pathname, char **pdir, char **ptail)
splitPathAtDirectory()
Definition: utils2.c:2728
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
Definition: utils2.c:2138
l_ok l_binaryWrite(const char *filename, const char *operation, const void *data, size_t nbytes)
l_binaryWrite()
Definition: utils2.c:1519
FILE * fopenReadStream(const char *filename)
fopenReadStream()
Definition: utils2.c:1864
l_uint8 * l_binaryRead(const char *filename, size_t *pnbytes)
l_binaryRead()
Definition: utils2.c:1310
l_uint8 * zlibCompress(const l_uint8 *datain, size_t nin, size_t *pnout)
zlibCompress()
Definition: zlibmem.c:92