|
l_int32 | setMsgSeverity (l_int32 newsev) |
|
l_int32 | returnErrorInt (const char *msg, const char *procname, l_int32 ival) |
|
l_float32 | returnErrorFloat (const char *msg, const char *procname, l_float32 fval) |
|
void * | returnErrorPtr (const char *msg, const char *procname, void *pval) |
|
static void | lept_default_stderr_handler (const char *formatted_msg) |
|
void | leptSetStderrHandler (void(*handler)(const char *)) |
|
void | lept_stderr (const char *fmt,...) |
|
l_ok | filesAreIdentical (const char *fname1, const char *fname2, l_int32 *psame) |
|
l_uint16 | convertOnLittleEnd16 (l_uint16 shortin) |
|
l_uint16 | convertOnBigEnd16 (l_uint16 shortin) |
|
l_uint32 | convertOnLittleEnd32 (l_uint32 wordin) |
|
l_uint32 | convertOnBigEnd32 (l_uint32 wordin) |
|
l_ok | fileCorruptByDeletion (const char *filein, l_float32 loc, l_float32 size, const char *fileout) |
|
l_ok | fileCorruptByMutation (const char *filein, l_float32 loc, l_float32 size, const char *fileout) |
|
l_ok | fileReplaceBytes (const char *filein, l_int32 start, l_int32 nbytes, l_uint8 *newdata, size_t newsize, const char *fileout) |
|
l_ok | genRandomIntOnInterval (l_int32 start, l_int32 end, l_int32 seed, l_int32 *pval) |
|
l_int32 | lept_roundftoi (l_float32 fval) |
|
l_ok | l_hashStringToUint64 (const char *str, l_uint64 *phash) |
|
l_ok | l_hashStringToUint64Fast (const char *str, l_uint64 *phash) |
|
l_ok | l_hashPtToUint64 (l_int32 x, l_int32 y, l_uint64 *phash) |
|
l_ok | l_hashFloat64ToUint64 (l_float64 val, l_uint64 *phash) |
|
l_ok | findNextLargerPrime (l_int32 start, l_uint32 *pprime) |
|
l_ok | lept_isPrime (l_uint64 n, l_int32 *pis_prime, l_uint32 *pfactor) |
|
l_uint32 | convertIntToGrayCode (l_uint32 val) |
|
l_uint32 | convertGrayCodeToInt (l_uint32 val) |
|
char * | getLeptonicaVersion (void) |
|
void | startTimer (void) |
|
l_float32 | stopTimer (void) |
|
L_TIMER | startTimerNested (void) |
|
l_float32 | stopTimerNested (L_TIMER rusage_start) |
|
void | l_getCurrentTime (l_int32 *sec, l_int32 *usec) |
|
L_WALLTIMER * | startWallTimer (void) |
|
l_float32 | stopWallTimer (L_WALLTIMER **ptimer) |
|
char * | l_getFormattedDate (void) |
|
------------------------------------------
This file has these utilities:
Definition in file utils1.c.
l_ok fileCorruptByDeletion |
( |
const char * |
filein, |
|
|
l_float32 |
loc, |
|
|
l_float32 |
size, |
|
|
const char * |
fileout |
|
) |
| |
fileCorruptByDeletion()
- Parameters
-
[in] | filein | |
[in] | loc | fractional location of start of deletion |
[in] | size | fractional size of deletion |
[in] | fileout | corrupted file |
- Returns
- 0 if OK, 1 on error
Notes:
(1) loc and size are expressed as a fraction of the file size.
(2) This makes a copy of the data in filein, where bytes in the
specified region have deleted.
(3) If (loc + size) >= 1.0, this deletes from the position
represented by loc to the end of the file.
(4) It is useful for testing robustness of I/O wrappers when the
data is corrupted, by simulating data corruption by deletion.
Definition at line 478 of file utils1.c.
References l_binaryRead(), and l_binaryWrite().
l_ok fileCorruptByMutation |
( |
const char * |
filein, |
|
|
l_float32 |
loc, |
|
|
l_float32 |
size, |
|
|
const char * |
fileout |
|
) |
| |
fileCorruptByMutation()
- Parameters
-
[in] | filein | |
[in] | loc | fractional location of start of randomization |
[in] | size | fractional size of randomization |
[in] | fileout | corrupted file |
- Returns
- 0 if OK, 1 on error
Notes:
(1) loc and size are expressed as a fraction of the file size.
(2) This makes a copy of the data in filein, where bytes in the
specified region have been replaced by random data.
(3) If (loc + size) >= 1.0, this modifies data from the position
represented by loc to the end of the file.
(4) It is useful for testing robustness of I/O wrappers when the
data is corrupted, by simulating data corruption.
Definition at line 542 of file utils1.c.
References l_binaryRead(), and l_binaryWrite().
l_ok fileReplaceBytes |
( |
const char * |
filein, |
|
|
l_int32 |
start, |
|
|
l_int32 |
nbytes, |
|
|
l_uint8 * |
newdata, |
|
|
size_t |
newsize, |
|
|
const char * |
fileout |
|
) |
| |
fileReplaceBytes()
- Parameters
-
[in] | filein | input file |
[in] | start | start location for replacement |
[in] | nbytes | number of bytes to be removed |
[in] | newdata | replacement bytes |
[in] | newsize | size of replacement bytes |
[in] | fileout | output file |
- Returns
- 0 if OK, 1 on error
Notes:
(1) To remove nbytes without replacement, set newdata == NULL.
(2) One use is for replacing the date/time in a pdf file by a
string of 12 '0's, effectively removing the date without
invalidating the byte counters in the pdf file:
fileReplaceBytes(filein 86 12 (char *)"000000000000" 12 fileout
Definition at line 603 of file utils1.c.
References l_binaryRead(), and l_binaryWrite().
l_ok l_hashStringToUint64Fast |
( |
const char * |
str, |
|
|
l_uint64 * |
phash |
|
) |
| |
l_hashStringToUint64Fast()
- Parameters
-
[in] | str | |
[out] | phash | hash value |
- Returns
- 0 if OK, 1 on error
Notes:
(1) This very simple hash algorithm is described in "The Practice
of Programming" by Kernighan and Pike, p. 57 (1999).
(2) The returned hash value would then be hashed into an index into
the hashtable, using the mod operator with the hashtable size.
Definition at line 771 of file utils1.c.
Referenced by l_hmapCreateFromSarray(), and sarrayIntersectionByHmap().
void lept_stderr |
( |
const char * |
fmt, |
|
|
|
... |
|
) |
| |
lept_stderr()
- Parameters
-
[in] | fmt | format string |
[in] | ... | varargs |
- Returns
- void
Notes:
(1) This is a replacement for fprintf(), to allow redirection
of output. All calls to fprintf(stderr, ...) are replaced
with calls to lept_stderr(...).
(2) The message size is limited to 2K bytes.
(3) This utility was provided by jbarlow83.
Definition at line 306 of file utils1.c.
Referenced by barcodeDecode2of5(), barcodeDecode39(), barcodeDecode93(), barcodeDecodeCodabar(), barcodeDecodeEan13(), barcodeDecodeI2of5(), barcodeDecodeUpca(), bilateralCreate(), boxaaQuadtreeRegions(), boxaWriteStderr(), boxPrintStreamInfo(), convertG4ToPSString(), dewarpaInfo(), dewarpaShowArrays(), dewarpaTestForValidModel(), dewarpDebug(), dewarpShowResults(), evalColorfillData(), findHistoGridDimensions(), kernelCreateFromString(), l_dnaWriteStderr(), l_showIndicatorSplitValues(), linearInterpolatePixelColor(), linearInterpolatePixelFloat(), linearInterpolatePixelGray(), medianCutApply(), morphSequenceVerify(), numaEvalBestHaarParameters(), numaEvalBestWidthAndShift(), numaSelectCrossingThreshold(), numaSplitDistribution(), numaWriteStderr(), parseTrailerPdf(), pixaComparePhotoRegionsByHisto(), pixAffineSequential(), pixApplyHorizDisparity(), pixApplyVertDisparity(), pixaSplitIntoFiles(), pixAutoPhotoinvert(), pixCompareWithTranslation(), pixSearchBinaryMaze(), rasteropGeneralLow(), rasteropLow(), recogAddAllSamples(), recogDebugAverages(), recogRescoreDidResult(), recogShowAverageTemplates(), regTestCleanup(), regTestComparePix(), regTestCompareSimilarPix(), regTestCompareStrings(), regTestCompareValues(), returnErrorFloat(), returnErrorInt(), returnErrorPtr(), rotateAMColorFastLow(), saConvertFilesToPdfData(), saConvertUnscaledFilesToPdfData(), sarrayWriteStderr(), scaleGrayAreaMapLow(), selaCreateFromFile(), setPixelLow(), sudokuGenerate(), sudokuSolve(), vboxGetAverageColor(), writeCustomTiffTags(), and zlibUncompress().
L_TIMER startTimerNested |
( |
void |
| ) |
|
startTimerNested(), stopTimerNested()
Example of usage:
L_TIMER t1 = startTimerNested();
....
L_TIMER t2 = startTimerNested();
....
lept_stderr( "Elapsed time 2 = %7.3f sec\n", stopTimerNested(t2));
....
lept_stderr( "Elapsed time 1 = %7.3f sec\n", stopTimerNested(t1));
Definition at line 1073 of file utils1.c.