35const char *strcasestr(
const char *s1,
const char *s2)
40 size_t n = strlen(s2);
43 if( !strnicmp( s1++, s2,n ) )
128 if( strlen( s ) == 0 )
134 while(*start && isspace(*start))
137 char *end = s + strlen( s ) - 1 ;
139 while( *end && isspace( *end) && end > s )
179 if( !fgets( buffer, size, stream ) )
184 if( it == ( size - 1 ) )
186 n_log(
LOG_DEBUG,
"buffer %p size %d fully filled by fgets on stream %p", buffer, size, stream );
204 nstr -> written = 0 ;
205 memset( nstr -> data, 0, nstr -> length );
230 Malloc( str -> data,
char, size + 1 );
232 str -> length = size ;
250 n_log(
LOG_ERR,
"destination N_STR **str is not NULL (%p), it contain (%s). You must provide an empty destination.", (*to), ((*to)&&(*to)->data)?(*to)->data:
"DATA_IS_NULL" );
260 memcpy( (*to) -> data, from, nboct );
261 (*to) -> written = nboct ;
275 N_STR *strptr = NULL ;
276 size_t length = strlen( src );
293 n_log(
LOG_ERR,
"destination N_STR **str is not NULL (%p), it contain (%s). You must provide an empty destination.", (*to), ((*to)&&(*to)->data)?(*to)->data:
"DATA_IS_NULL" );
304 (*to) -> data = from ;
306 (*to) -> written = nboct ;
320 N_STR *strptr = NULL ;
334 N_STR *tmpstr = NULL ;
335 struct stat filestat ;
340 if( stat( filename, &filestat ) != 0 )
343 if( errno == EOVERFLOW )
345 n_log(
LOG_ERR,
"%s size is too big ,EOVERFLOW)", filename );
350 n_log(
LOG_ERR,
"Couldn't stat %s. Errno: %s", filename, strerror( errno ) );
356 if( ( filestat . st_size + 1 ) >= ( pow( 2, 32 ) - 1 ) )
358 n_log(
LOG_ERR,
"file size >= 2GB is not possible yet. %s is %lld oct", filename, filestat . st_size );
362 n_log(
LOG_DEBUG,
"%s file size is: %lld", filename, (
long long unsigned int)filestat . st_size );
364 in = fopen( filename,
"rb" );
367 tmpstr =
new_nstr( filestat . st_size + 1 );
368 __n_assert( tmpstr, fclose( in );
n_log(
LOG_ERR,
"Unable to get a new nstr of %ld octets", filestat . st_size + 1 );
return NULL );
370 tmpstr -> written = filestat . st_size ;
372 if( fread( tmpstr -> data,
sizeof(
char ), tmpstr -> written, in ) == 0 )
374 n_log(
LOG_ERR,
"Couldn't read %s, fread return 0", filename );
381 n_log(
LOG_ERR,
"There were some errors when reading %s", filename );
405 struct flock out_lock ;
415 memset( &out_lock, 0,
sizeof( out_lock ) );
416 out_lock.l_type = F_WRLCK ;
418 fcntl( fileno( out ), F_SETLKW, &out_lock );
424 size_t written_to_file = 0 ;
425 if( (written_to_file = fwrite( str -> data,
sizeof(
char ), str -> written, out ) ) != (
size_t)str -> written )
427 n_log(
LOG_ERR,
"Couldn't write file, fwrite %d of %d octets", written_to_file, str -> written );
432 n_log(
LOG_ERR,
"There were some errors when writing to %d", fileno( out ) );
439 memset( &out_lock, 0,
sizeof( out_lock ) );
440 out_lock.l_type = F_WRLCK ;
442 fcntl( fileno( out ), F_SETLKW, &out_lock );
466 out = fopen( filename,
"wb" );
474 n_log(
LOG_DEBUG,
"%s file size is: %lld", filename, str ->written );
494 char *tmpstr = NULL ;
495 char *endstr = NULL ;
500 Malloc( tmpstr,
char,
sizeof(
int ) + end - start + 8 );
501 __n_assert( tmpstr,
n_log(
LOG_ERR,
"Unable to Malloc( tmpstr , char , sizeof( int ) + %d - %d )", end, start );
return FALSE );
503 memcpy( tmpstr, s + start, end - start );
506 l = strtol(tmpstr, &endstr, base);
507 if( ( errno == ERANGE && l == LONG_MAX) || l > INT_MAX )
509 n_log(
LOG_ERR,
"OVERFLOW reached when converting %s to int", tmpstr );
513 if( ( errno == ERANGE && l == LONG_MIN) || l < INT_MIN )
515 n_log(
LOG_ERR,
"UNDERFLOW reached when converting %s to int", tmpstr );
519 if( *endstr !=
'\0' && *endstr !=
'\n' )
521 n_log(
LOG_ERR,
"Impossible conversion for %s", tmpstr );
547 char *tmpstr = NULL ;
548 char *endstr = NULL ;
553 Malloc( tmpstr,
char,
sizeof(
int ) + end - start + 8 );
554 __n_assert( tmpstr,
n_log(
LOG_ERR,
"Unable to Malloc( tmpstr , char , sizeof( int ) + %d - %d )", end, start );
return FALSE );
556 memcpy( tmpstr, s + start, end - start );
559 l = strtol(tmpstr, &endstr, base);
560 if( ( errno == ERANGE && l == LONG_MAX) || l > INT_MAX )
562 nstrprintf( (*infos),
"OVERFLOW reached when converting %s to int", tmpstr );
566 if( ( errno == ERANGE && l == LONG_MIN) || l < INT_MIN )
568 nstrprintf( (*infos),
"UNDERFLOW reached when converting %s to int", tmpstr );
572 if( *endstr !=
'\0' && *endstr !=
'\n' )
574 nstrprintf( (*infos),
"Impossible conversion for %s", tmpstr );
617 char *tmpstr = NULL ;
618 char *endstr = NULL ;
623 Malloc( tmpstr,
char,
sizeof(
int ) + end - start + 8 );
624 __n_assert( tmpstr,
n_log(
LOG_ERR,
"Unable to Malloc( tmpstr , char , sizeof( int ) + %d - %d )", end, start );
return FALSE );
626 memcpy( tmpstr, s + start, end - start );
629 l = strtol(tmpstr, &endstr, base);
633 if (tmpstr == endstr)
635 n_log(
LOG_ERR,
" number : %lu invalid (no digits found, 0 returned)", l );
639 else if (error == ERANGE && l == LONG_MIN)
641 n_log(
LOG_ERR,
" number : %lu invalid (underflow occurred)", l );
645 else if (error == ERANGE && l == LONG_MAX)
647 n_log(
LOG_ERR,
" number : %lu invalid (overflow occurred)", l );
651 else if (error == EINVAL)
653 n_log(
LOG_ERR,
" number : %lu invalid (base contains unsupported value)", l );
657 else if (error != 0 && l == 0)
660 n_log(
LOG_ERR,
" number : %lu invalid (unspecified error occurred)", l );
664 else if (error == 0 && tmpstr && !*endstr)
666 n_log(
LOG_DEBUG,
" number : %lu valid (and represents all characters read)", l );
668 else if (error == 0 && tmpstr && *endstr != 0)
670 n_log(
LOG_DEBUG,
" number : %lu valid (but additional characters remain", l );
690 char *tmpstr = NULL ;
691 char *endstr = NULL ;
696 Malloc( tmpstr,
char,
sizeof(
int ) + end - start + 8 );
697 __n_assert( tmpstr,
n_log(
LOG_ERR,
"Unable to Malloc( tmpstr , char , sizeof( int ) + %d - %d )", end, start );
return FALSE );
699 memcpy( tmpstr, s + start, end - start );
702 l = strtoll(tmpstr, &endstr, base);
706 if (tmpstr == endstr)
708 n_log(
LOG_ERR,
"number: '%s' invalid (no digits found, 0 returned)", s );
712 else if (error == ERANGE && l == LLONG_MIN)
714 n_log(
LOG_ERR,
"number: '%s' invalid (underflow occurred)", s );
718 else if (error == ERANGE && l == LLONG_MAX)
720 n_log(
LOG_ERR,
"number: 's' invalid (overflow occurred)", s );
724 else if (error == EINVAL)
726 n_log(
LOG_ERR,
"number: '%s' invalid (base contains unsupported value)", s );
730 else if (error != 0 && l == 0)
733 n_log(
LOG_ERR,
"number: '%s' invalid (unspecified error occurred)", s );
737 else if (error == 0 && tmpstr && !*endstr)
739 n_log(
LOG_DEBUG,
"number : '%llu' valid (and represents all characters read)", l );
741 else if (error == 0 && tmpstr && *endstr != 0)
743 n_log(
LOG_DEBUG,
" number : '%llu' valid (remaining characters: '%s')", l , s );
797 N_STR *new_str = NULL ;
802 new_str =
new_nstr( str -> length );
805 if( new_str -> data )
807 memcpy( new_str -> data, str -> data, str -> written );
808 new_str -> length = str -> length ;
809 new_str -> written = str -> written ;
814 n_log(
LOG_ERR,
"Error duplicating N_STR %p -> data", str );
845 while( *iterator <= (
NSTRBYTE)strlen (
string ) && isspace(
string[ *iterator ] ) )
847 if( inc < 0 && *iterator == 0 )
853 *iterator = *iterator + inc;
858 while( *iterator <= (
NSTRBYTE)strlen(
string ) &&
string[ *iterator ] == toskip )
860 if( inc < 0 && *iterator == 0 )
866 *iterator = *iterator + inc;
869 if( error_flag == 1 || *iterator > (
NSTRBYTE)strlen (
string ) )
899 while( *iterator <= (
NSTRBYTE)strlen (
string ) && !isspace(
string[ *iterator ] ) )
901 if( inc < 0 && *iterator == 0 )
907 *iterator = *iterator + inc;
912 while( *iterator <= (
NSTRBYTE)strlen(
string ) &&
string[ *iterator ] != toskip )
914 if( inc < 0 && *iterator == 0 )
920 *iterator = *iterator + inc;
924 if( error_flag == 1 || *iterator > (
NSTRBYTE)strlen (
string ) )
942int strup(
char *
string,
char *dest )
950 for( it = 0 ; it < (
NSTRBYTE)strlen(
string ) ; it++ )
951 dest[ it ] = toupper (
string[ it ] );
965int strlo(
char *
string,
char *dest )
973 for( it = 0 ; it < (
NSTRBYTE)strlen(
string ) ; it++ )
974 dest[ it ] = tolower (
string[ it ] );
998 while( _it < to_size && from[ (*it) ] !=
'\0' && from[ (*it) ] !=
split )
1000 to[ _it ] = from[ (*it) ] ;
1005 if( _it == to_size )
1009 n_log(
LOG_DEBUG,
"strcpy_u: not enough space to write %d octet to dest (%d max) , %s: %d \n", _it, to_size, __FILE__, __LINE__ );
1015 if( from[ (*it) ] !=
split )
1017 n_log(
LOG_DEBUG,
"strcpy_u: split value not found, written %d octet to dest (%d max) , %s: %d \n", _it, to_size, __FILE__, __LINE__ );
1032char**
split(
const char* str,
const char* delim,
int empty )
1038 const char* largestring = NULL;
1043 int sizeDelim=strlen(delim);
1046 while( ( ptr = strstr( largestring, delim ) ) != NULL )
1048 sizeStr=ptr-largestring;
1049 if( empty == 1 || sizeStr != 0 )
1052 tab= (
char**) realloc(tab,
sizeof(
char*)*sizeTab);
1054 Malloc( tab[sizeTab -1],
char, (
int)(
sizeof(
char)*(sizeStr+1)) );
1055 __n_assert( tab[ sizeTab - 1 ],
goto error );
1057 memcpy(tab[sizeTab-1],largestring,sizeStr);
1058 tab[sizeTab-1][sizeStr]=
'\0';
1065 if( strlen(largestring) !=0 )
1067 sizeStr=strlen(largestring);
1070 tab= (
char**) realloc(tab,
sizeof(
char*)*sizeTab);
1072 Malloc( tab[sizeTab-1],
char,(
int)(
sizeof(
char)*(sizeStr+1) ) );
1073 __n_assert( tab[ sizeTab - 1 ],
goto error );
1075 memcpy(tab[sizeTab-1],largestring,sizeStr);
1076 tab[sizeTab-1][sizeStr]=
'\0';
1083 tab= (
char**) realloc(tab,
sizeof(
char*)*sizeTab);
1085 Malloc( tab[sizeTab-1],
char, (
int)(
sizeof(
char)*1) );
1086 __n_assert( tab[ sizeTab - 1 ],
goto error );
1088 tab[sizeTab-1][0]=
'\0';
1094 tab= (
char**) realloc(tab,
sizeof(
char*)*sizeTab);
1095 tab[sizeTab-1]=NULL;
1117 while( split_result[ it ] )
1137 while( (*tab)[ it ] )
1139 Free( (*tab)[ it ] );
1153char*
join(
char** splitresult ,
char *delim )
1155 size_t delim_length = 0 ;
1157 delim_length = strlen( delim );
1158 size_t total_length = 0 ;
1160 while( splitresult[ it ] )
1163 total_length += strlen( splitresult[ it ] );
1165 if( delim && splitresult[ it + 1 ] )
1166 total_length += delim_length ;
1169 char *result = NULL ;
1170 Malloc( result ,
char , total_length + 1 );
1171 size_t position = 0 ;
1173 while( splitresult[ it ] )
1175 size_t copy_size = strlen( splitresult[ it ] );
1176 memcpy( &result[ position ] , splitresult[ it ] , copy_size );
1177 position += copy_size ;
1179 if( delim && splitresult[ it + 1 ] )
1181 memcpy( &result[ position ] , delim , delim_length );
1182 position += delim_length ;
1210 if( ( dest -> written + size + 1 ) > dest -> length && resize_flag == 0 )
1212 n_log(
LOG_ERR,
"%p to %p: not enough space. Resize forbidden. %lld needed, %lld available", dest, src, dest -> written + size + 1, dest -> length );
1222 if( dest -> length < dest -> written + size + 1 )
1224 dest -> length = dest -> written + size + 1 ;
1225 Reallocz( dest -> data,
char, dest -> written , dest -> length );
1229 ptr = dest -> data + dest -> written ;
1230 memcpy( ptr, src, size );
1231 dest -> written += size ;
1233 dest -> data[ dest -> written ] =
'\0' ;
1248 return nstrcat_ex( dst, src -> data, src -> written, 1 );
1267 n_log(
LOG_ERR,
"Could not copy 0 or less (%ld) octet!", size );
1286 NSTRBYTE size = strlen( (
char *)data );
1289 n_log(
LOG_ERR,
"Could not copy 0 or less (%ld) octet!", size );
1313 NSTRBYTE needed_size = (*written) + src_size + 1 ;
1316 if( ( needed_size >= (*size) ) || !(*dest) )
1323 Reallocz( (*dest),
char, (*size), needed_size + additional_padding );
1324 (*size) = needed_size ;
1331 ptr = (*dest) + (*written) ;
1332 memcpy( ptr, src, src_size );
1333 (*written) += src_size ;
1334 (*dest)[ (*written) ] =
'\0' ;
1365 return scan_dir_ex( dir,
"*", result, recurse, 0 );
1379int scan_dir_ex(
const char *dir,
const char *pattern,
LIST *result,
const int recurse,
const int mode )
1382 struct dirent *entry = NULL;
1383 struct stat statbuf;
1388 if( ( dp = opendir( dir ) ) == NULL)
1394 N_STR *newname = NULL ;
1395 while( ( entry = readdir( dp ) ) != NULL )
1397 nstrprintf( newname,
"%s/%s", dir, entry -> d_name );
1399 if( stat( newname -> data, &statbuf ) >= 0 )
1401 if( S_ISDIR( statbuf . st_mode ) != 0 )
1403 if( strcmp(
".", entry -> d_name ) == 0 || strcmp(
"..", entry -> d_name ) == 0 )
1410 if( recurse != FALSE )
1412 if(
scan_dir_ex( newname -> data, pattern, result, recurse, mode ) != TRUE )
1414 n_log(
LOG_ERR,
"scan_dir_ex( %s , %s , %p , %d , %d ) returned FALSE !", newname -> data, pattern, result, recurse, mode );
1420 else if( S_ISREG( statbuf . st_mode ) != 0 )
1422 if(
wildmatcase( newname -> data, pattern ) == TRUE )
1426 char *file = strdup( newname -> data );
1433 n_log(
LOG_ERR,
"Error adding %s/%s to list", dir, entry -> d_name );
1436 else if( mode == 1 )
1459int wildmat(
register const char *text,
register const char *p)
1461 register int last = 0 ;
1462 register int matched = 0;
1463 register int reverse = 0;
1465 for ( ; *p; text++, p++)
1467 if (*text ==
'\0' && *p !=
'*')
1490 if ((matched =
wildmat(text++, p)) != FALSE)
1499 if (p[1] ==
']' || p[1] ==
'-')
1502 for (last = *p; *++p && *p !=
']'; last = *p)
1504 if (*p ==
'-' && p[1] !=
']'
1505 ? *text <= *++p && *text >= last : *text == *p)
1507 if (matched == reverse)
1512#ifdef WILDMAT_MATCH_TAR_PATTERN
1516 return *text ==
'\0';
1530 register int matched;
1531 register int reverse;
1533 for ( ; *p; text++, p++)
1535 if (*text ==
'\0' && *p !=
'*')
1544 if (toupper(*text) != toupper(*p))
1567 if (p[1] ==
']' || p[1] ==
'-')
1568 if (toupper(*++p) == toupper(*text))
1570 for (last = toupper(*p); *++p && *p !=
']'; last = toupper(*p))
1571 if (*p ==
'-' && p[1] !=
']'
1572 ? toupper(*text) <= toupper(*++p) && toupper(*text) >= last : toupper(*text) == toupper(*p))
1574 if (matched == reverse)
1579#ifdef WILDMAT_MATCH_TAR_PATTERN
1583 return *text ==
'\0';
1598char *
str_replace (
const char *
string,
const char *substr,
const char *replacement )
1601 char *newstr = NULL;
1602 char *oldstr = NULL;
1606 if ( substr == NULL || replacement == NULL )
1607 return strdup (
string);
1608 newstr = strdup (
string);
1610 while ( (tok = strstr ( head, substr )))
1613 Malloc( newstr,
char, strlen ( oldstr ) - strlen ( substr ) + strlen ( replacement ) + 8 );
1615 if ( newstr == NULL )
1620 memcpy ( newstr, oldstr, tok - oldstr );
1621 memcpy ( newstr + (tok - oldstr), replacement, strlen ( replacement ) );
1622 memcpy ( newstr + (tok - oldstr) + strlen( replacement ), tok + strlen ( substr ), strlen ( oldstr ) - strlen ( substr ) - ( tok - oldstr ) );
1623 memset ( newstr + strlen ( oldstr ) - strlen ( substr ) + strlen ( replacement ), 0, 1 );
1625 head = newstr + (tok - oldstr) + strlen( replacement );
1646 for( it = 0 ; it < string_len ; it ++ )
1649 while( mask_it<masklen && mask[mask_it]!=
'\0')
1651 if(
string[ it ] == mask[ mask_it ] )
1652 string[ it ] = replacement ;
1669 return str_sanitize_ex(
string, strlen(
string ), mask, strlen( mask ), replacement );
#define FreeNoLog(__ptr)
Free Handler without log.
#define Malloc(__ptr, __struct, __size)
Malloc Handler to get errors and set to 0.
#define __n_assert(__ptr, __ret)
macro to assert things
#define _str(__PTR)
define true
#define Reallocz(__ptr, __struct, __old_size, __size)
Realloc + zero new memory zone Handler to get errors.
#define Free(__ptr)
Free Handler to get errors.
int list_push(LIST *list, void *ptr, void(*destructor)(void *ptr))
Add a pointer to the end of the list.
Structure of a generic LIST container.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_ERR
error conditions
int str_to_long_long(const char *s, long long int *i, const int base)
Helper for string to integer.
int strcpy_u(char *from, char *to, NSTRBYTE to_size, char split, NSTRBYTE *it)
Copy from start to dest until from[ iterator ] == split.
int nstrcat(N_STR *dst, N_STR *src)
Add N_STR *src content to N_STR *dst, resizing it if needed.
char * trim_nocopy(char *s)
trim and zero end the string, WARNING: keep and original pointer to delete the string correctly
void free_nstr_ptr(void *ptr)
Free a N_STR pointer structure.
size_t NSTRBYTE
N_STR base unit.
#define free_nstr(__ptr)
free a N_STR structure and set the pointer to NULL
int split_count(char **split_result)
Count split elements.
#define nstrprintf(__nstr_var,...)
Macro to quickly allocate and sprintf to N_STR *.
int str_sanitize_ex(char *string, const NSTRBYTE string_len, const char *mask, const NSTRBYTE masklen, const char replacement)
clean a string by replacing evil characteres
int nstr_to_file(N_STR *str, char *filename)
Write a N_STR content into a file.
int scan_dir_ex(const char *dir, const char *pattern, LIST *result, const int recurse, const int mode)
Scan a list of directory and return a list of char *file.
int str_to_long_long_ex(const char *s, NSTRBYTE start, NSTRBYTE end, long long int *i, const int base)
Helper for string[start to end] to long long integer.
N_STR * nstrdup(N_STR *str)
Duplicate a N_STR.
int write_and_fit(char **dest, NSTRBYTE *size, NSTRBYTE *written, const char *src)
concatenate a copy of src of size strlen( src ) to dest, starting at dest[ written ],...
int nstrcat_bytes_ex(N_STR *dest, void *data, NSTRBYTE size)
Append data into N_STR using internal N_STR size and cursor position.
int nstrcat_bytes(N_STR *dest, void *data)
Append data into N_STR using internal N_STR size and cursor position.
int str_to_int_ex(const char *s, NSTRBYTE start, NSTRBYTE end, int *i, const int base)
Helper for string[start to end] to integer.
int str_to_int_nolog(const char *s, NSTRBYTE start, NSTRBYTE end, int *i, const int base, N_STR **infos)
Helper for string[start to end] to integer.
int char_to_nstr_nocopy_ex(char *from, NSTRBYTE nboct, N_STR **to)
Convert a char into a N_STR, direct use of linked source pointer, extended version.
N_STR * char_to_nstr(const char *src)
Convert a char into a N_STR, short version.
char * nfgets(char *buffer, NSTRBYTE size, FILE *stream)
try to fgets
int skipw(char *string, char toskip, NSTRBYTE *iterator, int inc)
skip while 'toskip' occurence is found from 'iterator' to the next non 'toskip' position.
#define WILDMAT_ABORT
Abort code to sped up pattern matching.
int empty_nstr(N_STR *nstr)
empty a N_STR string
int wildmatcase(register const char *text, register const char *p)
Written by Rich Salz rsalz at osf.org, refurbished by me.
#define WILDMAT_NEGATE_CLASS
What character marks an inverted character class?
N_STR * new_nstr(NSTRBYTE size)
create a new N_STR string
char * str_replace(const char *string, const char *substr, const char *replacement)
Replace "substr" by "replacement" inside string taken from http://coding.debuntu.org/c-implementing-s...
int scan_dir(const char *dir, LIST *result, const int recurse)
Scan a list of directory and return a list of char *file.
int str_sanitize(char *string, const char *mask, const char replacement)
clean a string by replacing evil characteres
char ** split(const char *str, const char *delim, int empty)
split the strings into a an array of char *pointer , ended by a NULL one.
int strup(char *string, char *dest)
Upper case a string.
int wildmat(register const char *text, register const char *p)
Written by Rich Salz rsalz at osf.org, refurbished by me.
int free_nstr_nolog(N_STR **ptr)
Free a N_STR structure and set the pointer to NULL.
int str_to_long(const char *s, long int *i, const int base)
Helper for string to integer.
int nstrcat_ex(N_STR *dest, void *src, NSTRBYTE size, int resize_flag)
Append data into N_STR using internal N_STR size and cursor position.
int char_to_nstr_ex(const char *from, NSTRBYTE nboct, N_STR **to)
Convert a char into a N_STR, extended version.
N_STR * char_to_nstr_nocopy(char *src)
Convert a char into a N_STR, direct use of linked source pointer, short version.
int _free_nstr(N_STR **ptr)
Free a N_STR structure and set the pointer to NULL.
int write_and_fit_ex(char **dest, NSTRBYTE *size, NSTRBYTE *written, const char *src, NSTRBYTE src_size, NSTRBYTE additional_padding)
concatenate a copy of src of size src_size to dest, starting at dest[ written ], updating written and...
char * join(char **splitresult, char *delim)
join the array into a string
N_STR * file_to_nstr(char *filename)
Load a whole file into a N_STR.
int free_split_result(char ***tab)
Free a split result allocated array.
void free_nstr_ptr_nolog(void *ptr)
Free a N_STR pointer structure.
int str_to_int(const char *s, int *i, const int base)
Helper for string to integer.
int skipu(char *string, char toskip, NSTRBYTE *iterator, int inc)
skip until 'toskip' occurence is found from 'iterator' to the next 'toskip' value.
char * trim(char *s)
trim and put a \0 at the end, return new char *
int strlo(char *string, char *dest)
Upper case a string.
int nstr_to_fd(N_STR *str, FILE *out, int lock)
Write a N_STR content into a file.
int str_to_long_ex(const char *s, NSTRBYTE start, NSTRBYTE end, long int *i, const int base)
Helper for string[start to end] to long integer.
A box including a string and his lenght.
Common headers and low-level hugly functions & define.
N_STR and string function declaration.