1 /*
2  * ----------------------------------------------------------------
3  * strcalls - String Functions Header
4  * ----------------------------------------------------------------
5  * Copyright (C) 1997-2009 Jonas Kvinge
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  * $Id: strcalls.h 54 2009-03-18 18:23:29Z jonasio $
21  *
22  */
23 
24 #ifdef STRCALLS_H
25 #warning "strcalls.h already included."
26 #else
27 #define STRCALLS_H
28 
29 
30 #define STRHOSTINVALIDCHAR						"Invalid character \"%c\" in hostname."
31 #define STRHOSTMAXCHARS							"Maximum %d characters in hostname."
32 #define STRFILEINVALIDCHAR						"Invalid character \"%c\" in filename."
33 #define STRFILEMAXCHARS							"Maximum %d characters in filename."
34 
35 
36 /* VARIABLES - JONAS (05.05.2000) */
37 
38 #ifdef STRCALLS_C
39   unsigned short int WMChars = 0;
40   char *UNAMEINFO = NULL;
41   char *PLATFORM = NULL;
42   char *HOSTNAME = NULL;
43   char *HOSTIPS = NULL;
44   unsigned long int HOSTIPH = 0;
45   unsigned long int HOSTIPN = 0;
46   char *OSNAME = NULL;
47   char *OSRELEASE = NULL;
48   char *STRDURATION = NULL;
49   char StrResult[LINELEN+1] = "";
50 #else
51   extern unsigned short int WMChars;
52   extern char *UNAMEINFO;
53   extern char *PLATFORM;
54   extern char *HOSTNAME;
55   extern char *HOSTIPS;
56   extern unsigned long int HOSTIPH;
57   extern unsigned long int HOSTIPN;
58   extern char *OSNAME;
59   extern char *OSRELEASE;
60   extern char *STRDURATION;
61   extern char StrResult[];
62 #endif
63 
64 
65 /* MACROS - JONAS (05.05.2000) */
66 
67 #undef strrealloc
68 #define strrealloc(p, s)	mystrrealloc(__FILE__, __LINE__, __FUNCTION__, (p), (s))
69 
70 #undef strwm
71 #define strwm(p, s)		mystrwm(__FILE__, __LINE__, __FUNCTION__, (p), (s), FALSE)
72 
73 #undef strfilefix
74 #define strfilefix strfilefix1
75 
76 /* FUNCTION PROTOTYPES - JONAS (27.04.2002) */
77 
78 const char *straerror(unsigned short int aerrnocode);
79 unsigned short int strisvalidhost(const char *const StringPT);
80 unsigned short int strisvalidfile(const char *const StringPT);
81 const char *strresult(void);
82 char *mystrrealloc(const char *FilePT, const unsigned long int Line, const char *const FunctionPT, char *OldPointer, const char *StringPT);
83 size_t mystrspn(const char *StringPT, const char *AcceptPT);
84 size_t strchrcnt(char *StringPT, const char Char);
85 unsigned short int mystrwm(const char *FilePT, const unsigned long int Line, const char *const FunctionPT, const char *PatternPT, const char *StringPT, unsigned short int Internal);
86 void strlower(char *StringPT);
87 void strupper(char *StringPT);
88 void strfilefix1(char *StringPT);
89 void strfilefix2(char *StringPT);
90 unsigned short int strdigit(const char *StringPT);
91 unsigned short int strip(const char *StringPT);
92 void strrnd(char *StringPT, const unsigned short int Len);
93 const char *datestamp(void);
94 const char *timestamp(void);
95 const char *dtstamp(void);
96 const char *strduration(const time_t Time);
97 void strgetunameinfo(void);
98 void strgetplatform(void);
99 void strgetosname(void);
100 void strgetosrelease(void);
101 void strgethostname(void);
102 char *straddbuffer(char *StringPT, const char *const BufferPT, const unsigned long int MaxStringLen, const unsigned short int AddLen);
103 void strcleanup(void);
104 
105 #endif
106