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
130
131
132
133
134
135
136
137
|
/*
* str.h
*
* Version: 2018-09-21
*
* Copyright (c) Chris Putnam 1999-2019
*
* Source code released under the GPL version 2
*
*/
#ifndef STR_H
#define STR_H
#define STR_OK (0)
#define STR_MEMERR (-1)
#include <stdio.h>
typedef struct str {
char *data;
unsigned long dim;
unsigned long len;
#ifndef STR_SMALL
int status;
#endif
} str;
str * str_new ( void );
void str_delete ( str *s );
void str_init ( str *s );
void str_initstr ( str *s, str *from );
void str_initstrc ( str *s, const char *initstr );
void str_initstrsc ( str *s, ... );
void str_empty ( str *s );
void str_free ( str *s );
void strs_init ( str *s, ... );
void strs_empty ( str *s, ... );
void strs_free ( str *s, ... );
str* str_strdup ( str *s );
str* str_strdupc( const char *p );
void str_strcat ( str *s, str *from );
void str_strcatc( str *s, const char *from );
void str_strcpy ( str *s, str *from );
void str_strcpyc( str *s, const char *from );
int str_strcmp ( const str *s, const str *t );
int str_strcmpc( const str *s, const char *t );
int str_strncmp ( const str *s, const str *t, size_t n );
int str_strncmpc( const str *s, const char *t, size_t n );
int str_strcasecmp ( const str *s, const str *t );
int str_strcasecmpc( const str *s, const char *t );
char * str_strstr ( const str *s, const str *t );
char * str_strstrc( const str *s, const char *t );
void str_prepend ( str *s, const char *addstr );
void str_mergestrs ( str *s, ... );
void str_addchar ( str *s, char newchar );
void str_reverse ( str *s );
const char *str_addutf8 ( str *s, const char *p );
void str_segcat ( str *s, char *startat, char *endat );
const char *str_cpytodelim ( str *s, const char *p, const char *delim, unsigned char finalstep );
const char *str_cattodelim ( str *s, const char *p, const char *delim, unsigned char finalstep );
void str_prepend ( str *s, const char *addstr );
void str_segcpy ( str *s, char *startat, char *endat );
void str_segdel ( str *s, char *startat, char *endat );
void str_indxcpy ( str *s, char *p, unsigned long start, unsigned long stop );
void str_indxcat ( str *s, char *p, unsigned long start, unsigned long stop );
void str_fprintf ( FILE *fp, str *s );
int str_fget ( FILE *fp, char *buf, int bufsize, int *pbufpos,
str *outs );
char * str_cstr ( str *s );
char str_char ( str *s, unsigned long n );
char str_revchar ( str *s, unsigned long n );
int str_fgetline ( str *s, FILE *fp );
int str_findreplace ( str *s, const char *find, const char *replace );
void str_toupper ( str *s );
void str_tolower ( str *s );
void str_trimstartingws( str *s );
void str_trimendingws( str *s );
void str_swapstrings ( str *s1, str *s2 );
void str_stripws ( str *s );
int str_match_first ( str *s, char ch );
int str_match_end ( str *s, char ch );
void str_trimbegin ( str *s, unsigned long n );
void str_trimend ( str *s, unsigned long n );
void str_pad ( str *s, unsigned long len, char ch );
void str_copyposlen ( str *s, str *in, unsigned long pos, unsigned long len );
void str_makepath ( str *path, const char *dirname, const char *filename, char sep );
void str_fill ( str *s, unsigned long n, char fillchar );
int str_is_mixedcase( str *s );
int str_is_lowercase( str *s );
int str_is_uppercase( str *s );
int str_memerr( str *s );
unsigned long str_strlen( str *s );
int str_has_value( str *s );
int str_is_empty( str *s );
/* #define STR_PARANOIA
*
* set to clear memory before it is freed or reallocated
* note that this is slower...may be important if string
* contains sensitive information
*/
/* #define STR_NOASSERT
*
* set to turn off the use of asserts (and associated call to exit)
* in str functions...useful for library construction for
* Linux distributions that don't want libraries calling exit, but
* not useful during code development
*/
/* #define STR_SMALL
*
* set to make the smallest possible struct str, but will get
* exit( EXIT_FAILURE ) upon memory failures
*/
#endif
|