2 * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3 * Copyright (C) 2005 QSDN,Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 #include "chxj_str_util.h"
20 chxj_chk_numeric(const char* s)
25 for (ii=0; ii<len; ii++) {
26 if (ii == 0 && (s[ii] < '0' || s[ii] > '9') && s[ii] != '-') {
29 if (ii != 0 && (s[ii] < '0' || s[ii] > '9')) {
40 chxj_atoi(const char* s)
49 for (ii=0; ii < len; ii++) {
52 case '0': result += 0; break;
53 case '1': result += 1; break;
54 case '2': result += 2; break;
55 case '3': result += 3; break;
56 case '4': result += 4; break;
57 case '5': result += 5; break;
58 case '6': result += 6; break;
59 case '7': result += 7; break;
60 case '8': result += 8; break;
61 case '9': result += 9; break;
79 chxj_strcasenrcmp(apr_pool_t *p, const char *s1, const char *s2, int n)
88 s1_len = strlen(s1) - 1;
89 s2_len = strlen(s2) - 1;
91 ss1 = (char *)apr_palloc(p, s1_len + 2);
95 ss2 = (char *)apr_palloc(p, s2_len + 2);
104 ss1p = &ss1[s1_len+1];
105 ss2p = &ss2[s2_len+1];
107 for (;*ss1p && *ss2p && *ss1p == *ss2p && n - 1 > 0; ss1p--, ss2p--, n--);
109 return (int)(*ss1p - *ss2p);
114 chxj_starts_with(const char *str, const char *word)
116 int len = strlen(word);
117 return strncasecmp(str, word, len) == 0;