File: string.h

package info (click to toggle)
yiff 2.14.5-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,344 kB
  • ctags: 3,360
  • sloc: ansic: 40,505; cpp: 7,420; makefile: 425; sh: 242
file content (129 lines) | stat: -rw-r--r-- 3,630 bytes parent folder | download | duplicates (7)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
                              String Utilities

	These string functions go on top of the string functions in
	string.h.
 */

#ifndef STRING_H
#define STRING_H	/* Not to be confused with standard _STRING_H */

#include <sys/types.h>
#include "../include/os.h"


#ifdef __cplusplus
extern "C" {
#endif


/* Checks if c is a space or tab character */
#ifndef ISBLANK
# define ISBLANK(c)	(((c) == ' ') || ((c) == '\t'))
#endif

/* Checks if c is a space, tab, vertical tab, form-feed, carrage
 * return or newline character
 */
#ifndef ISSPACE
# define ISSPACE(c)	(			\
	((c) == ' ') || ((c) == '\t') ||	\
	((c) == '\v') || ((c) == '\f') ||	\
	((c) == '\r') || ((c) == '\n')  	\
)
#endif


/* Line Checking */
extern int strlinelen(const char *s);
extern int strlongestline(const char *s);
extern int strlines(const char *s);

/* Comparing */
#ifdef NEED_STRCASECMP
extern int strcasecmp(const char *s1, const char *s2);
#endif
#ifdef NEED_STRCASESTR
extern char *strcasestr(const char *haystack, const char *needle);
#endif
extern int strpfx(const char *s, const char *pfx);
extern int strcasepfx(const char *s, const char *pfx);

/* Editing */
extern char *strinsstr(char *s, int i, const char *s2);
extern char *strinschr(char *s, int i, char c);
extern char *strdelchrs(char *s, int i, int n);
extern char *strdelchr(char *s, int i);
extern void strtoupper(char *s);
extern void strtolower(char *s);
extern char *strcatalloc(char *orig, const char *new_str);
extern void substr(char *s, const char *token, const char *val);
extern char *strsub(const char *fmt, const char *token, const char *val);
#ifndef WIN32
extern void strset(char *s, char c, int n);
#endif
extern void strpad(char *s, int n);
extern void straddflag(char *s, const char *flag, char operation, int len);
extern void strstriplead(char *s);
extern void strstriptail(char *s);
extern void strstrip(char *s);

/* Lists */
extern char **strlistinsert(char **strv, int *strc, const char *s, int i);
#define strlistins strlistinsert
extern char **strlistappend(char **strv, int *strc, const char *s);
#define strlistapp strlistappend
extern char **strlistdelete(char **strv, int *strc, int i);
#define strlistdel strlistdelete
extern char **strlistcopy(const char **strv, int strc);
extern void strlistfree(char **strv, int strc);

/* Sorting */
extern char **StringQSort(char **strings, int nitems);

extern char *StringTailSpaces(char *s, int len);
extern void StringShortenFL(char *s, int limit);

/* UNIX configruation file format string handling */
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" int StringIsYes(const char *s);
extern "C" int StringIsComment(const char *s, char c);
extern "C" char *StringCfgParseParm(const char *s);
extern "C" char *StringCfgParseValue(const char *s);
#else
extern int StringIsYes(const char *s);
extern int StringIsComment(const char *s, char c);
extern char *StringCfgParseParm(const char *s);
extern char *StringCfgParseValue(const char *s);
#endif

/* Misc string parsing */
extern int StringParseStdColor(
	const char *s,
	u_int8_t *r_rtn,
	u_int8_t *g_rtn,
	u_int8_t *b_rtn
);
extern int StringParseIP(
	const char *s,
	u_int8_t *c1,
	u_int8_t *c2,
	u_int8_t *c3,
	u_int8_t *c4
);

/* ShipWars CyberSpace network protocol string functions */
extern int StringGetNetCommand(const char *str);
extern char *StringGetNetArgument(const char *str);

/* Time string formatting */
extern char *StringCurrentTimeFormat(const char *format);
extern char *StringTimeFormat(const char *format, time_t seconds);
extern char *StringFormatTimePeriod(time_t seconds);


#ifdef __cplusplus
}
#endif

#endif /* STRING_H */