src/protocols/jabber/str.c

changeset 3127
4213ad5b231c
parent 2086
007508451e2c
child 3717
2fc0789e04e8
equal deleted inserted replaced
3126:2608079efd58 3127:4213ad5b231c
1 /* 1 /* --------------------------------------------------------------------------
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 * 2 *
7 * This program is distributed in the hope that it will be useful, 3 * License
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 * 4 *
12 * You should have received a copy of the GNU General Public License 5 * The contents of this file are subject to the Jabber Open Source License
13 * along with this program; if not, write to the Free Software 6 * Version 1.0 (the "JOSL"). You may not copy or use this file, in either
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 7 * source code or executable form, except in compliance with the JOSL. You
8 * may obtain a copy of the JOSL at http://www.jabber.org/ or at
9 * http://www.opensource.org/.
15 * 10 *
16 * Jabber 11 * Software distributed under the JOSL is distributed on an "AS IS" basis,
17 * Copyright (C) 1998-1999 The Jabber Team http://jabber.org/ 12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the JOSL
18 */ 13 * for the specific language governing rights and limitations under the
19 14 * JOSL.
20 #include "libxode.h" 15 *
16 * Copyrights
17 *
18 * Portions created by or assigned to Jabber.com, Inc. are
19 * Copyright (c) 1999-2002 Jabber.com, Inc. All Rights Reserved. Contact
20 * information for Jabber.com, Inc. is available at http://www.jabber.com/.
21 *
22 * Portions Copyright (c) 1998-1999 Jeremie Miller.
23 *
24 * Acknowledgements
25 *
26 * Special thanks to the Jabber Open Source Contributors for their
27 * suggestions and support of Jabber.
28 *
29 * Alternatively, the contents of this file may be used under the terms of the
30 * GNU General Public License Version 2 or later (the "GPL"), in which case
31 * the provisions of the GPL are applicable instead of those above. If you
32 * wish to allow use of your version of this file only under the terms of the
33 * GPL and not to allow others to use your version of this file under the JOSL,
34 * indicate your decision by deleting the provisions above and replace them
35 * with the notice and other provisions required by the GPL. If you do not
36 * delete the provisions above, a recipient may use your version of this file
37 * under either the JOSL or the GPL.
38 *
39 *
40 * --------------------------------------------------------------------------*/
41
42 #include "lib.h"
21 43
22 char *j_strdup(const char *str) 44 char *j_strdup(const char *str)
23 { 45 {
24 if(str == NULL) 46 if(str == NULL)
25 return NULL; 47 return NULL;
40 62
41 int j_strcmp(const char *a, const char *b) 63 int j_strcmp(const char *a, const char *b)
42 { 64 {
43 if(a == NULL || b == NULL) 65 if(a == NULL || b == NULL)
44 return -1; 66 return -1;
45 else 67
46 return strcmp(a, b); 68 while(*a == *b && *a != '\0' && *b != '\0'){ a++; b++; }
69
70 if(*a == *b) return 0;
71
72 return -1;
47 } 73 }
48 74
49 int j_strcasecmp(const char *a, const char *b) 75 int j_strcasecmp(const char *a, const char *b)
50 { 76 {
51 if(a == NULL || b == NULL) 77 if(a == NULL || b == NULL)
134 160
135 /* loop till we hit our end flag, the first arg */ 161 /* loop till we hit our end flag, the first arg */
136 while(1) 162 while(1)
137 { 163 {
138 arg = va_arg(ap,char *); 164 arg = va_arg(ap,char *);
139 if((int)arg == (int)s) 165 if((spool)arg == s)
140 break; 166 break;
141 else 167 else
142 spool_add(s, arg); 168 spool_add(s, arg);
143 } 169 }
144 170
183 209
184 /* loop till we hit our end flag, the first arg */ 210 /* loop till we hit our end flag, the first arg */
185 while(1) 211 while(1)
186 { 212 {
187 arg = va_arg(ap,char *); 213 arg = va_arg(ap,char *);
188 if((int)arg == (int)p) 214 if((pool)arg == p)
189 break; 215 break;
190 else 216 else
191 spool_add(s, arg); 217 spool_add(s, arg);
192 } 218 }
193 219
342 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* D0-DF */ 368 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* D0-DF */
343 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* E0-EF */ 369 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* E0-EF */
344 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 /* F0-FF */ 370 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 /* F0-FF */
345 }; 371 };
346 372
347 phase = 0; 373 d = dlast = phase = 0;
348 for (cur = str; *cur != '\0'; ++cur ) 374 for (cur = str; *cur != '\0'; ++cur )
349 { 375 {
350 d = table[(int)*cur]; 376 d = table[(int)*cur];
351 if(d != -1) 377 if(d != -1)
352 { 378 {

mercurial