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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
|
/*
* C-string functions
* Copyright Jan Engelhardt, 1999-2010
*
* This file is part of libHX. libHX is free software; you can
* redistribute it and/or modify it under the terms of the GNU Lesser
* General Public License as published by the Free Software Foundation;
* either version 2.1 or (at your option) any later version.
*/
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libHX/ctype_helper.h>
#include <libHX/string.h>
#include "internal.h"
/**
* %HXQUOTE_ACCEPT: the listed characters are passed through,
* all others need to be quoted
* %HXQUOTE_REJECT: the listed characters need to be quoted,
* all others pass through
*/
enum HX_quote_selector {
HXQUOTE_ACCEPT,
HXQUOTE_REJECT,
};
/**
* @selector: whether this rule is accept- or reject-based
* @qchars: characters that need (no) quoting
*/
struct HX_quote_rule {
char selector;
const char *chars;
};
static const char HX_hexenc[16] = "0123456789ABCDEF";
static __inline__ unsigned int min_uint(unsigned int a, unsigned int b)
{
return (a < b) ? a : b;
}
EXPORT_SYMBOL char *HX_basename(const char *s)
{
const char *p;
/* ignore trailing slashes */
for (p = s + strlen(s) - 1; p >= s && *p == '/'; --p)
;
if (p < s)
/*
* String contained only slashes - this must be the root
* directory. Since we have the opportunity, rather than
* returning "////", just give the cleaned-up "/".
*/
return const_cast1(char *, s + strlen(s) - 1);
if ((p = HX_strbchr(s, p, '/')) != NULL)
return const_cast1(char *, p + 1);
return const_cast1(char *, s);
}
EXPORT_SYMBOL char *HX_basename_exact(const char *s)
{
const char *start, *end;
char *ret;
int len;
if (*s == '\0')
return HX_strdup(".");
/* ignore trailing slashes */
for (end = s + strlen(s) - 1; end >= s && *end == '/'; --end)
;
if (end < s)
/* string consisted of only slashes */
return HX_strdup("/");
start = HX_strbchr(s, end, '/');
if (start == NULL) {
len = end - s + 1;
ret = HX_memdup(s, len + 1);
} else {
++start;
len = end - start + 1;
ret = HX_memdup(start, len + 1);
}
if (ret == NULL)
return NULL;
ret[len] = '\0';
return ret;
}
EXPORT_SYMBOL char *HX_chomp(char *s)
{
char *p = s + strlen(s) - 1;
while (p >= s) {
if (*p != '\n' && *p != '\r')
break;
*p-- = '\0';
}
return s;
}
EXPORT_SYMBOL char *HX_dirname(const char *s)
{
const char *last, *stop;
char *p;
if (*s == '\0')
return HX_strdup(".");
for (last = s + strlen(s) - 1; last > s && *last == '/'; --last)
;
if ((stop = HX_strbchr(s, last, '/')) == NULL)
return HX_strdup(".");
for (; stop > s && *stop == '/'; --stop)
;
p = HX_memdup(s, stop - s + 2);
p[stop-s+1] = '\0';
return p;
}
EXPORT_SYMBOL hxmc_t *HX_getl(hxmc_t **ptr, FILE *fp)
{
/* Read a whole line into a dynamic buffer. */
char temp[MAXLNLEN];
if (fgets(temp, sizeof(temp), fp) == NULL)
return NULL;
if (*ptr == NULL) {
*ptr = HXmc_meminit(NULL, 0);
if (*ptr == NULL)
return NULL;
} else {
HXmc_trunc(ptr, 0);
}
do {
if (HXmc_strcat(ptr, temp) == NULL)
return *ptr;
if (strchr(temp, '\n') != NULL)
break;
} while (fgets(temp, sizeof(temp), fp) != NULL);
return *ptr;
}
EXPORT_SYMBOL void *HX_memmem(const void *vspace, size_t spacesize,
const void *vpoint, size_t pointsize)
{
const char *space = vspace, *point = vpoint;
const char *head, *end;
size_t tailsize;
char *tail;
if (pointsize == 0)
return const_cast1(void *, vspace);
if (pointsize > spacesize)
return NULL;
/* Do a BM-style trailer search and reduce calls to memcmp */
head = space + (pointsize - 1);
tail = memchr(head, point[pointsize-1], spacesize - (pointsize - 1));
if (tail == NULL || pointsize == 1)
return tail;
end = space + spacesize;
do {
head = tail - pointsize + 1;
if (memcmp(head, point, pointsize) == 0)
return const_cast(char *, head);
++tail;
tailsize = end - tail;
tail = memchr(tail, point[pointsize-1], tailsize);
} while (tail != NULL);
return NULL;
}
EXPORT_SYMBOL char **HX_split(const char *str, const char *delim,
int *cp, int max)
{
/*
* @countp can be NULL in case you are not interested in the number of
* fields. In either case, you can find out the number of fields by
* scanning through the resulting vector.
*/
int count = 0;
char **ret;
if (cp == NULL)
cp = &count;
*cp = 1;
{
const char *wp = str;
while ((wp = strpbrk(wp, delim)) != NULL) {
if (++*cp >= max && max > 0) {
*cp = max;
break;
}
++wp;
}
}
if (max == 0 || *cp < max)
max = *cp;
else if (*cp > max)
*cp = max;
ret = malloc(sizeof(char *) * (*cp + 1));
ret[*cp] = NULL;
{
char *seg, *wp = HX_strdup(str), *bg = wp;
size_t i = 0;
while (--max > 0) {
seg = HX_strsep(&wp, delim);
ret[i++] = HX_strdup(seg);
}
ret[i++] = HX_strdup(wp);
free(bg);
}
return ret;
}
EXPORT_SYMBOL char **HX_split_inplace(char *s, const char *delim, int *fld, int max)
{
char **stk;
const char *p = s;
int count = 1;
for (p = strpbrk(p, delim); p != NULL; p = strpbrk(++p, delim))
if (++count >= max && max > 0) {
count = max;
break;
}
stk = malloc(sizeof(char *) * (count + 1));
if (stk == NULL)
return NULL;
stk[count] = NULL;
count = HX_split_fixed(s, delim, count, stk);
if (fld != NULL)
*fld = count;
return stk;
}
EXPORT_SYMBOL int HX_split_fixed(char *s, const char *delim, int max, char **stk)
{
/*
* HX_split_fixed - the "stack split" (we try to avoid using the heap):
* Split @s (modifies it, so must be writable!) at @delim with at most
* @max fields and putting the results into @stk[0..@max-1].
*
* Example on @max:
* char *stk[max];
* HX_split_fixed(s, delim, max, stk);
*/
int i = 0;
char *p;
while (--max > 0) {
if ((p = strpbrk(s, delim)) == NULL)
break;
stk[i++] = s;
*p = '\0';
s = p + 1;
}
stk[i++] = s;
return i;
}
EXPORT_SYMBOL char *HX_strbchr(const char *start, const char *now, char d)
{
/* Find the last occurrence of @d within @start and (including) @now. */
while (now >= start)
if (*now-- == d)
return const_cast1(char *, ++now);
return NULL;
}
/**
* This is the counterpart to strpbrk(). Returns a pointer to the first
* character not in @accept, or otherwise %NULL.
*/
EXPORT_SYMBOL char *HX_strchr2(const char *s, const char *accept)
{
size_t seg = strspn(s, accept);
if (s[seg] == '\0')
return NULL;
return const_cast1(char *, s + seg);
}
EXPORT_SYMBOL char *HX_strclone(char **pa, const char *pb)
{
if (*pa == pb)
return *pa;
if (*pa != NULL) {
free(*pa);
*pa = NULL;
}
if (pb == NULL)
return NULL;
if ((*pa = malloc(strlen(pb) + 1)) == NULL)
return NULL;
strcpy(*pa, pb);
return *pa;
}
EXPORT_SYMBOL char *HX_strdup(const char *src)
{
if (src == NULL)
return NULL;
/* return HX_strndup(src, SIZE_MAX); */
return HX_memdup(src, strlen(src) + 1);
}
EXPORT_SYMBOL char *HX_strlcat(char *dest, const char *src, size_t len)
{
ssize_t x = len - strlen(dest) - 1;
if (x <= 0)
return dest;
return strncat(dest, src, x);
}
EXPORT_SYMBOL char *HX_strlcpy(char *dest, const char *src, size_t n)
{
if (n == 0)
return dest;
strncpy(dest, src, n);
dest[n-1] = '\0';
return dest;
}
EXPORT_SYMBOL char *HX_strlncat(char *dest, const char *src, size_t dlen,
size_t slen)
{
ssize_t x = dlen - strlen(dest) - 1;
if (x <= 0)
return dest;
x = ((ssize_t)slen < x) ? (ssize_t)slen : x;
return strncat(dest, src, x);
}
EXPORT_SYMBOL char *HX_strlower(char *orig)
{
char *expr;
for (expr = orig; *expr != '\0'; ++expr)
*expr = HX_tolower(*expr);
return orig;
}
EXPORT_SYMBOL size_t HX_strltrim(char *expr)
{
char *travp;
size_t diff = 0;
travp = expr;
while (HX_isspace(*travp))
++travp;
if ((diff = travp - expr) > 0)
memmove(expr, travp, strlen(travp) + 1);
return diff;
}
EXPORT_SYMBOL char *HX_stpltrim(const char *p)
{
while (HX_isspace(*p))
++p;
return const_cast1(char *, p);
}
/* supports negative offsets like scripting languages */
EXPORT_SYMBOL char *HX_strmid(const char *expr, long offset, long length)
{
char *buffer;
if (offset < 0)
offset = strlen(expr) + offset;
if (length < 0)
length = strlen(expr) - offset + length;
if ((buffer = malloc(length + 1)) == NULL)
return NULL;
expr += offset;
return HX_strlcpy(buffer, expr, length + 1);
}
EXPORT_SYMBOL char *HX_strndup(const char *src, size_t size)
{
char *ret;
size_t z;
if (src == NULL)
return NULL;
z = strlen(src);
if (z < size)
size = z;
if ((ret = malloc(size + 1)) == NULL)
return NULL;
memcpy(ret, src, size);
ret[size] = '\0';
return ret;
}
EXPORT_SYMBOL size_t HX_strnlen(const char *src, size_t size)
{
const char *ptr = src;
for (; *ptr != '\0' && size > 0; --size, ++ptr)
;
return ptr - src;
}
EXPORT_SYMBOL size_t HX_strrcspn(const char *s, const char *rej)
{
size_t n = strlen(s);
const char *p = s + n;
while (--p >= s)
if (strchr(rej, *p) != NULL)
return p - s;
return n;
}
EXPORT_SYMBOL char *HX_strrev(char *s)
{
size_t i, z = strlen(s)-1, z2 = z / 2;
for (i = 0; i < z2; ++i) {
char temp;
temp = s[i];
s[i] = s[z-i];
s[z-i] = temp;
}
return s;
}
EXPORT_SYMBOL size_t HX_strrtrim(char *expr)
{
int i = strlen(expr), s = 0;
while (i-- && HX_isspace(expr[i]))
++s;
expr[++i] = '\0';
return s;
}
EXPORT_SYMBOL char *HX_strsep(char **sp, const char *d)
{
char *begin, *end;
if (*sp == NULL || **sp == '\0')
return NULL;
begin = *sp;
if (d[0] == '\0' || d[1] == '\0') {
if (*begin == *d)
end = begin;
else if (*begin == '\0')
end = NULL;
else
end = strchr(begin + 1, *d);
} else {
end = strpbrk(begin, d);
}
if (end == NULL) {
*sp = NULL;
} else {
*end++ = '\0';
*sp = end;
}
return begin;
}
EXPORT_SYMBOL char *HX_strsep2(char **wp, const char *str)
{
char *ptr, *ret;
if (*wp == NULL)
return NULL;
ret = *wp;
if ((ptr = strstr(*wp, str)) == NULL) {
*wp = NULL;
return ret;
}
*ptr = '\0';
*wp = ptr + strlen(str);
return ret;
}
static const struct HX_quote_rule HX_quote_rules[] = {
[HXQUOTE_SQUOTE] = {HXQUOTE_REJECT, "'\\"},
[HXQUOTE_DQUOTE] = {HXQUOTE_REJECT, "\"\\"},
[HXQUOTE_HTML] = {HXQUOTE_REJECT, "\"&<>"},
[HXQUOTE_LDAPFLT] = {HXQUOTE_REJECT, "\n*()\\"},
[HXQUOTE_LDAPRDN] = {HXQUOTE_REJECT, "\n \"#+,;<=>\\"},
[HXQUOTE_URIENC] = {HXQUOTE_ACCEPT, "-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~"},
[HXQUOTE_SQLSQUOTE] = {HXQUOTE_REJECT, "'"},
[HXQUOTE_SQLBQUOTE] = {HXQUOTE_REJECT, "`"},
};
/**
* HX_qsize_bsa - calculate length of statically expanded string (for accepts)
* @s: input string
* @qchars: characters that need quoting
* @cost: quoting cost per quoted character
*
* The cost depends on the quote format. Typical values:
* 1 when "&" becomes "\&" (programming language-like)
* 2 when "&" becomes "\26" (LDAPRDN/HTTPURI-like hex encoding)
* 3 when "&" becomes "\x26" (hex encoding for programming)
*/
static size_t
HX_qsize_bsa(const char *s, const char *qchars, unsigned int cost)
{
const char *p = s;
size_t n = strlen(s);
while ((p = HX_strchr2(p, qchars)) != NULL) {
n += cost;
++p;
}
return n;
}
/**
* HX_qsize_bsr - calculate length of statically expanded string (for rejects)
* @s: input string
* @qchars: characters that need quoting
* @cost: quoting cost per quoted character
*
* Same as for HX_qsize_bsa, but for HXQUOTE_REJECT-type rules.
*/
static size_t
HX_qsize_bsr(const char *s, const char *qchars, unsigned int cost)
{
const char *p = s;
size_t n = strlen(s);
while ((p = strpbrk(p, qchars)) != NULL) {
n += cost;
++p;
}
return n;
}
static char *HX_quote_backslash(char *dest, const char *src, const char *qc)
{
char *ret = dest;
size_t len;
while (*src != '\0') {
len = strcspn(src, qc);
if (len > 0) {
memcpy(dest, src, len);
dest += len;
src += len;
if (*src == '\0')
break;
}
*dest++ = '\\';
*dest++ = *src++;
}
*dest = '\0';
return ret;
}
static char *
HX_quote_sqlbackslash(char *dest, const char *src, const char *trm)
{
char *ret = dest;
size_t len;
while (*src != '\0') {
len = strcspn(src, trm);
if (len > 0) {
memcpy(dest, src, len);
dest += len;
src += len;
if (*src == '\0')
break;
}
*dest++ = *trm;
*dest++ = *trm;
++src;
}
*dest = '\0';
return ret;
}
/**
* Encode @src into BASE-64 according to RFC 4648 and write result to @dest,
* which must be of appropriate size, plus one for a trailing NUL.
*/
static char *HX_quote_base64(char *d, const char *s)
{
static const char a[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz0123456789+/";
size_t len = strlen(s);
char *ret = d;
while (len > 0) {
if (len >= 3) {
len -= 3;
d[0] = a[(s[0] & 0xFC) >> 2];
d[1] = a[((s[0] & 0x03) << 4) | ((s[1] & 0xF0) >> 4)];
d[2] = a[((s[1] & 0x0F) << 2) | ((s[2] & 0xC0) >> 6)];
d[3] = a[s[2] & 0x3F];
} else if (len == 2) {
len = 0;
d[0] = a[(s[0] & 0xFC) >> 2];
d[1] = a[((s[0] & 0x03) << 4) | ((s[1] & 0xF0) >> 4)];
d[2] = a[(s[1] & 0x0F) << 2];
d[3] = '=';
} else if (len == 1) {
len = 0;
d[0] = a[(s[0] & 0xFC) >> 2];
d[1] = a[(s[0] & 0x03) << 4];
d[2] = '=';
d[3] = '=';
}
s += 3;
d += 4;
}
*d = '\0';
return ret;
}
static size_t HX_qsize_html(const char *s)
{
const char *p = s;
size_t n = strlen(s);
while ((p = strpbrk(p, HX_quote_rules[HXQUOTE_HTML].chars)) != NULL) {
switch (*p) {
/* minus 2: \0 and the original char */
case '"':
n += sizeof(""") - 2;
break;
case '&':
n += sizeof("&") - 2;
break;
case '<':
case '>':
n += sizeof("<") - 2;
break;
}
++p;
}
return n;
}
static char *HX_quote_html(char *dest, const char *src)
{
#define put(s) do { \
memcpy(dest, (s), sizeof(s) - 1); \
dest += sizeof(s) - 1; \
} while (false);
char *ret = dest;
while (*src != '\0') {
size_t len = strcspn(src, HX_quote_rules[HXQUOTE_HTML].chars);
if (len > 0) {
memcpy(dest, src, len);
dest += len;
src += len;
if (*src == '\0')
break;
}
switch (*src++) {
case '"': put("""); break;
case '&': put("&"); break;
case '<': put("<"); break;
case '>': put(">"); break;
}
}
*dest = '\0';
return ret;
#undef put
}
static char *HX_quote_ldap(char *dest, const char *src, const char *qc)
{
char *ret = dest;
size_t len;
while (*src != '\0') {
len = strcspn(src, qc);
if (len > 0) {
memcpy(dest, src, len);
dest += len;
src += len;
if (*src == '\0')
break;
}
*dest++ = '\\';
*dest++ = HX_hexenc[(*src >> 4) & 0x0F];
*dest++ = HX_hexenc[*src++ & 0x0F];
}
*dest = '\0';
return ret;
}
static char *HX_quote_urlenc(char *dest, const char *src)
{
char *ret = dest;
size_t len;
while (*src != '\0') {
len = strspn(src, HX_quote_rules[HXQUOTE_URIENC].chars);
if (len > 0) {
memcpy(dest, src, len);
dest += len;
src += len;
if (*src == '\0')
break;
}
*dest++ = '%';
*dest++ = HX_hexenc[(*src >> 4) & 0x0F];
*dest++ = HX_hexenc[*src++ & 0x0F];
}
*dest = '\0';
return ret;
}
/**
* HX_quoted_size -
* @s: string to analyze
* @type: quoting method
*
* Returns the size of the string @s when quoted.
*/
static size_t HX_quoted_size(const char *s, unsigned int type)
{
switch (type) {
case HXQUOTE_SQUOTE:
case HXQUOTE_DQUOTE:
case HXQUOTE_SQLSQUOTE:
case HXQUOTE_SQLBQUOTE:
return HX_qsize_bsr(s, HX_quote_rules[type].chars, 1);
case HXQUOTE_HTML:
return HX_qsize_html(s);
case HXQUOTE_LDAPFLT:
case HXQUOTE_LDAPRDN:
return HX_qsize_bsr(s, HX_quote_rules[type].chars, 2);
case HXQUOTE_BASE64:
return (strlen(s) + 2) / 3 * 4;
case HXQUOTE_URIENC:
return HX_qsize_bsa(s, HX_quote_rules[type].chars, 2);
default:
return strlen(s);
}
}
EXPORT_SYMBOL char *HX_strquote(const char *src, unsigned int type,
char **free_me)
{
const struct HX_quote_rule *rule;
bool do_quote;
char *tmp;
if (type >= _HXQUOTE_MAX) {
errno = EINVAL;
return NULL;
}
/* If quote_chars is NULL, it is clear all chars are to be encoded. */
rule = &HX_quote_rules[type];
if (type >= ARRAY_SIZE(HX_quote_rules) || rule->chars == NULL)
do_quote = true;
else if (rule->selector == HXQUOTE_REJECT)
do_quote = strpbrk(src, rule->chars) != NULL;
else if (rule->selector == HXQUOTE_ACCEPT)
do_quote = HX_strchr2(src, rule->chars) != NULL;
else
do_quote = false;
/*
* free_me == NULL implies that we always allocate, even if
* there is nothing to quote.
*/
if (free_me != NULL) {
free(*free_me);
*free_me = NULL;
if (!do_quote)
return const_cast1(char *, src);
} else {
if (!do_quote)
return HX_strdup(src);
free_me = &tmp;
}
*free_me = malloc(HX_quoted_size(src, type) + 1);
if (*free_me == NULL)
return NULL;
switch (type) {
case HXQUOTE_SQUOTE:
case HXQUOTE_DQUOTE:
return HX_quote_backslash(*free_me, src, rule->chars);
case HXQUOTE_HTML:
return HX_quote_html(*free_me, src);
case HXQUOTE_LDAPFLT:
case HXQUOTE_LDAPRDN:
return HX_quote_ldap(*free_me, src, rule->chars);
case HXQUOTE_BASE64:
return HX_quote_base64(*free_me, src);
case HXQUOTE_URIENC:
return HX_quote_urlenc(*free_me, src);
case HXQUOTE_SQLSQUOTE:
case HXQUOTE_SQLBQUOTE:
return HX_quote_sqlbackslash(*free_me, src, rule->chars);
}
return NULL;
}
EXPORT_SYMBOL char *HX_strupper(char *orig)
{
char *expr;
for (expr = orig; *expr != '\0'; ++expr)
*expr = HX_toupper(*expr);
return orig;
}
|