summaryrefslogtreecommitdiff
path: root/tools/MakeDef/h_util.h
blob: 8f3862000c91ed7628fb497d785bfa0c5487dd2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#if !defined( __UTIL_H )
   #define __UTIL_H

   #if !defined( __STDARG_H )
      #include <stdarg.h>
      #define __STDARG_H
   #endif

   #if !defined( __TTYPES_H )
      #include "h_types.h"
   #endif

//-------------------------- Useful functions ----------------------------

char* copyString( char* dest, char* src, size_t size );

char* centerStr( char *dest, const char *src, size_t len );
char* rightJust( char *string, size_t size );
char* leftJust ( char *string, size_t size );

char* strToUpper( char* );
char* strToLower( char* );

uchar charToUpper( uchar );
uchar charToLower( uchar );

char* ltrim(char*);
char* rtrim(char*);
char* strdel(char*, size_t);
char* trim(char*);
char* newStr(const char*);
void  placeString(char* pDest, char* pSrc, size_t pLen);

bool  fileExists(char* fileName);

char* replaceExt(const char* fileName, char* ext, char* buffer);
int   shareFile(const char* fileName, bool ifRead, bool ifWrite);

//----------------- Ôóíêöèè äëÿ ðàáîòû ñ ðàñøèðåííûìè ñòðîêàìè ----------------

int     cstrlen(const char *);
size_t  getStrNumber(char* sText);
size_t  getStrLength(char* sText);
char*   xstrncpy(char* dest, const char* src, size_t iLen);

long CRC32(uchar*, size_t);

#define FIELD_DELTA( CLS, FLD ) (( int )( (( char* )( &(( CLS* )1 )->FLD )) - (( char* )( CLS* )1 )))

#endif  // __UTIL_H