-rw-r--r-- | libical/src/libical/sspm.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/libical/src/libical/sspm.c b/libical/src/libical/sspm.c index 2df581b..17f12ee 100644 --- a/libical/src/libical/sspm.c +++ b/libical/src/libical/sspm.c | |||
@@ -1,163 +1,160 @@ | |||
1 | /* -*- Mode: C -*- | 1 | /* -*- Mode: C -*- |
2 | ====================================================================== | 2 | ====================================================================== |
3 | FILE: sspm.c Parse Mime | 3 | FILE: sspm.c Parse Mime |
4 | CREATOR: eric 25 June 2000 | 4 | CREATOR: eric 25 June 2000 |
5 | 5 | ||
6 | $Id$ | 6 | $Id$ |
7 | $Locker$ | 7 | $Locker$ |
8 | 8 | ||
9 | The contents of this file are subject to the Mozilla Public License | 9 | The contents of this file are subject to the Mozilla Public License |
10 | Version 1.0 (the "License"); you may not use this file except in | 10 | Version 1.0 (the "License"); you may not use this file except in |
11 | compliance with the License. You may obtain a copy of the License at | 11 | compliance with the License. You may obtain a copy of the License at |
12 | http://www.mozilla.org/MPL/ | 12 | http://www.mozilla.org/MPL/ |
13 | 13 | ||
14 | Software distributed under the License is distributed on an "AS IS" | 14 | Software distributed under the License is distributed on an "AS IS" |
15 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See | 15 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See |
16 | the License for the specific language governing rights and | 16 | the License for the specific language governing rights and |
17 | limitations under the License. | 17 | limitations under the License. |
18 | 18 | ||
19 | 19 | ||
20 | This program is free software; you can redistribute it and/or modify | 20 | This program is free software; you can redistribute it and/or modify |
21 | it under the terms of either: | 21 | it under the terms of either: |
22 | 22 | ||
23 | The LGPL as published by the Free Software Foundation, version | 23 | The LGPL as published by the Free Software Foundation, version |
24 | 2.1, available at: http://www.fsf.org/copyleft/lesser.html | 24 | 2.1, available at: http://www.fsf.org/copyleft/lesser.html |
25 | 25 | ||
26 | Or: | 26 | Or: |
27 | 27 | ||
28 | The Mozilla Public License Version 1.0. You may obtain a copy of | 28 | The Mozilla Public License Version 1.0. You may obtain a copy of |
29 | the License at http://www.mozilla.org/MPL/ | 29 | the License at http://www.mozilla.org/MPL/ |
30 | 30 | ||
31 | The Initial Developer of the Original Code is Eric Busboom | 31 | The Initial Developer of the Original Code is Eric Busboom |
32 | 32 | ||
33 | (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org | 33 | (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org |
34 | ======================================================================*/ | 34 | ======================================================================*/ |
35 | 35 | ||
36 | #include <stdio.h> | 36 | #include <stdio.h> |
37 | #include <string.h> | 37 | #include <string.h> |
38 | #include "sspm.h" | 38 | #include "sspm.h" |
39 | #include <assert.h> | 39 | #include <assert.h> |
40 | #include <ctype.h> /* for tolower */ | 40 | #include <ctype.h> /* for tolower */ |
41 | #include <stdlib.h> /* for malloc, free */ | 41 | #include <stdlib.h> /* for malloc, free */ |
42 | #include <string.h> /* for strcasecmp */ | 42 | #include <string.h> /* for strcasecmp */ |
43 | 43 | ||
44 | // Eugen C. <eug@thekompany.com> | ||
45 | #ifdef _WIN32 | ||
46 | #define strcasecmp _stricmp | ||
47 | #endif | ||
48 | // Eugen C. <eug@thekompany.com> | ||
49 | |||
50 | int snprintf(char *str, size_t n, char const *fmt, ...); | ||
51 | |||
52 | #ifdef DMALLOC | 44 | #ifdef DMALLOC |
53 | #include "dmalloc.h" | 45 | #include "dmalloc.h" |
54 | #endif | 46 | #endif |
55 | 47 | ||
48 | #ifdef WIN32 | ||
49 | #define snprintf _snprintf | ||
50 | #define strcasecmp stricmp | ||
51 | #endif | ||
52 | |||
56 | #define TMP_BUF_SIZE 1024 | 53 | #define TMP_BUF_SIZE 1024 |
57 | 54 | ||
58 | 55 | ||
59 | enum mime_state { | 56 | enum mime_state { |
60 | UNKNOWN_STATE, | 57 | UNKNOWN_STATE, |
61 | IN_HEADER, | 58 | IN_HEADER, |
62 | END_OF_HEADER, | 59 | END_OF_HEADER, |
63 | IN_BODY, | 60 | IN_BODY, |
64 | OPENING_PART, | 61 | OPENING_PART, |
65 | END_OF_PART, | 62 | END_OF_PART, |
66 | TERMINAL_END_OF_PART, | 63 | TERMINAL_END_OF_PART, |
67 | END_OF_INPUT | 64 | END_OF_INPUT |
68 | }; | 65 | }; |
69 | 66 | ||
70 | struct mime_impl{ | 67 | struct mime_impl{ |
71 | struct sspm_part *parts; | 68 | struct sspm_part *parts; |
72 | size_t max_parts; | 69 | size_t max_parts; |
73 | int part_no; | 70 | int part_no; |
74 | int level; | 71 | int level; |
75 | struct sspm_action_map *actions; | 72 | struct sspm_action_map *actions; |
76 | char* (*get_string)(char *s, size_t size, void* data); | 73 | char* (*get_string)(char *s, size_t size, void* data); |
77 | void* get_string_data; | 74 | void* get_string_data; |
78 | char temp[TMP_BUF_SIZE]; | 75 | char temp[TMP_BUF_SIZE]; |
79 | enum mime_state state; | 76 | enum mime_state state; |
80 | }; | 77 | }; |
81 | 78 | ||
82 | void sspm_free_header(struct sspm_header *header); | 79 | void sspm_free_header(struct sspm_header *header); |
83 | void* sspm_make_multipart_part(struct mime_impl *impl,struct sspm_header *header); | 80 | void* sspm_make_multipart_part(struct mime_impl *impl,struct sspm_header *header); |
84 | void sspm_read_header(struct mime_impl *impl,struct sspm_header *header); | 81 | void sspm_read_header(struct mime_impl *impl,struct sspm_header *header); |
85 | 82 | ||
86 | char* sspm_strdup(char* str){ | 83 | char* sspm_strdup(char* str){ |
87 | 84 | ||
88 | char* s; | 85 | char* s; |
89 | 86 | ||
90 | s = strdup(str); | 87 | s = strdup(str); |
91 | 88 | ||
92 | return s; | 89 | return s; |
93 | } | 90 | } |
94 | 91 | ||
95 | 92 | ||
96 | struct major_content_type_map | 93 | static struct major_content_type_map |
97 | { | 94 | { |
98 | enum sspm_major_type type; | 95 | enum sspm_major_type type; |
99 | char* str; | 96 | char* str; |
100 | 97 | ||
101 | } major_content_type_map[] = | 98 | } major_content_type_map[] = |
102 | { | 99 | { |
103 | {SSPM_MULTIPART_MAJOR_TYPE,"multipart" }, | 100 | {SSPM_MULTIPART_MAJOR_TYPE,"multipart" }, |
104 | {SSPM_TEXT_MAJOR_TYPE,"text" }, | 101 | {SSPM_TEXT_MAJOR_TYPE,"text" }, |
105 | {SSPM_TEXT_MAJOR_TYPE,"text" }, | 102 | {SSPM_TEXT_MAJOR_TYPE,"text" }, |
106 | {SSPM_IMAGE_MAJOR_TYPE,"image" }, | 103 | {SSPM_IMAGE_MAJOR_TYPE,"image" }, |
107 | {SSPM_AUDIO_MAJOR_TYPE,"audio" }, | 104 | {SSPM_AUDIO_MAJOR_TYPE,"audio" }, |
108 | {SSPM_VIDEO_MAJOR_TYPE,"video" }, | 105 | {SSPM_VIDEO_MAJOR_TYPE,"video" }, |
109 | {SSPM_APPLICATION_MAJOR_TYPE,"application" }, | 106 | {SSPM_APPLICATION_MAJOR_TYPE,"application" }, |
110 | {SSPM_MULTIPART_MAJOR_TYPE,"multipart" }, | 107 | {SSPM_MULTIPART_MAJOR_TYPE,"multipart" }, |
111 | {SSPM_MESSAGE_MAJOR_TYPE,"message" }, | 108 | {SSPM_MESSAGE_MAJOR_TYPE,"message" }, |
112 | {SSPM_UNKNOWN_MAJOR_TYPE,"" }, | 109 | {SSPM_UNKNOWN_MAJOR_TYPE,"" }, |
113 | }; | 110 | }; |
114 | 111 | ||
115 | struct minor_content_type_map | 112 | static struct minor_content_type_map |
116 | { | 113 | { |
117 | enum sspm_minor_type type; | 114 | enum sspm_minor_type type; |
118 | char* str; | 115 | char* str; |
119 | 116 | ||
120 | } minor_content_type_map[] = | 117 | } minor_content_type_map[] = |
121 | { | 118 | { |
122 | {SSPM_ANY_MINOR_TYPE,"*" }, | 119 | {SSPM_ANY_MINOR_TYPE,"*" }, |
123 | {SSPM_PLAIN_MINOR_TYPE,"plain" }, | 120 | {SSPM_PLAIN_MINOR_TYPE,"plain" }, |
124 | {SSPM_RFC822_MINOR_TYPE,"rfc822" }, | 121 | {SSPM_RFC822_MINOR_TYPE,"rfc822" }, |
125 | {SSPM_DIGEST_MINOR_TYPE,"digest" }, | 122 | {SSPM_DIGEST_MINOR_TYPE,"digest" }, |
126 | {SSPM_CALENDAR_MINOR_TYPE,"calendar" }, | 123 | {SSPM_CALENDAR_MINOR_TYPE,"calendar" }, |
127 | {SSPM_MIXED_MINOR_TYPE,"mixed" }, | 124 | {SSPM_MIXED_MINOR_TYPE,"mixed" }, |
128 | {SSPM_RELATED_MINOR_TYPE,"related" }, | 125 | {SSPM_RELATED_MINOR_TYPE,"related" }, |
129 | {SSPM_ALTERNATIVE_MINOR_TYPE,"alternative" }, | 126 | {SSPM_ALTERNATIVE_MINOR_TYPE,"alternative" }, |
130 | {SSPM_PARALLEL_MINOR_TYPE, "parallel" }, | 127 | {SSPM_PARALLEL_MINOR_TYPE, "parallel" }, |
131 | {SSPM_UNKNOWN_MINOR_TYPE,"" } | 128 | {SSPM_UNKNOWN_MINOR_TYPE,"" } |
132 | }; | 129 | }; |
133 | 130 | ||
134 | 131 | ||
135 | 132 | ||
136 | struct encoding_map { | 133 | struct encoding_map { |
137 | enum sspm_encoding encoding; | 134 | enum sspm_encoding encoding; |
138 | char* str; | 135 | char* str; |
139 | } sspm_encoding_map[] = | 136 | } sspm_encoding_map[] = |
140 | { | 137 | { |
141 | {SSPM_NO_ENCODING,""}, | 138 | {SSPM_NO_ENCODING,""}, |
142 | {SSPM_QUOTED_PRINTABLE_ENCODING,"quoted-printable"}, | 139 | {SSPM_QUOTED_PRINTABLE_ENCODING,"quoted-printable"}, |
143 | {SSPM_8BIT_ENCODING,"8bit"}, | 140 | {SSPM_8BIT_ENCODING,"8bit"}, |
144 | {SSPM_7BIT_ENCODING,"7bit"}, | 141 | {SSPM_7BIT_ENCODING,"7bit"}, |
145 | {SSPM_BINARY_ENCODING,"binary"}, | 142 | {SSPM_BINARY_ENCODING,"binary"}, |
146 | {SSPM_BASE64_ENCODING,"base64"}, | 143 | {SSPM_BASE64_ENCODING,"base64"}, |
147 | {SSPM_UNKNOWN_ENCODING,""} | 144 | {SSPM_UNKNOWN_ENCODING,""} |
148 | 145 | ||
149 | }; | 146 | }; |
150 | 147 | ||
151 | 148 | ||
152 | char* sspm_get_parameter(char* line, char* parameter) | 149 | char* sspm_get_parameter(char* line, char* parameter) |
153 | { | 150 | { |
154 | char *p,*s,*q; | 151 | char *p,*s,*q; |
155 | static char name[1024]; | 152 | static char name[1024]; |
156 | 153 | ||
157 | /* Find where the parameter name is in the line */ | 154 | /* Find where the parameter name is in the line */ |
158 | p = strstr(line,parameter); | 155 | p = strstr(line,parameter); |
159 | 156 | ||
160 | if( p == 0){ | 157 | if( p == 0){ |
161 | return 0; | 158 | return 0; |
162 | } | 159 | } |
163 | 160 | ||
@@ -196,97 +193,97 @@ char* sspm_get_parameter(char* line, char* parameter) | |||
196 | 193 | ||
197 | return name; | 194 | return name; |
198 | } | 195 | } |
199 | 196 | ||
200 | char* sspm_property_name(char* line) | 197 | char* sspm_property_name(char* line) |
201 | { | 198 | { |
202 | static char name[1024]; | 199 | static char name[1024]; |
203 | char *c = strchr(line,':'); | 200 | char *c = strchr(line,':'); |
204 | 201 | ||
205 | if(c != 0){ | 202 | if(c != 0){ |
206 | strncpy(name,line,(size_t)c-(size_t)line); | 203 | strncpy(name,line,(size_t)c-(size_t)line); |
207 | name[(size_t)c-(size_t)line] = '\0'; | 204 | name[(size_t)c-(size_t)line] = '\0'; |
208 | return name; | 205 | return name; |
209 | } else { | 206 | } else { |
210 | return 0; | 207 | return 0; |
211 | } | 208 | } |
212 | } | 209 | } |
213 | 210 | ||
214 | char* sspm_value(char* line) | 211 | char* sspm_value(char* line) |
215 | { | 212 | { |
216 | static char value[1024]; | 213 | static char value[1024]; |
217 | 214 | ||
218 | char *c,*s, *p; | 215 | char *c,*s, *p; |
219 | 216 | ||
220 | /* Find the first colon and the next semicolon */ | 217 | /* Find the first colon and the next semicolon */ |
221 | 218 | ||
222 | c = strchr(line,':'); | 219 | c = strchr(line,':'); |
223 | s = strchr(c,';'); | 220 | s = strchr(c,';'); |
224 | 221 | ||
225 | /* Skip the colon */ | 222 | /* Skip the colon */ |
226 | c++; | 223 | c++; |
227 | 224 | ||
228 | if (s == 0){ | 225 | if (s == 0){ |
229 | s = c+strlen(line); | 226 | s = c+strlen(line); |
230 | } | 227 | } |
231 | 228 | ||
232 | for(p=value; c != s; c++){ | 229 | for(p=value; c != s; c++){ |
233 | if(*c!=' ' && *c!='\n'){ | 230 | if(*c!=' ' && *c!='\n'){ |
234 | *(p++) = *c; | 231 | *(p++) = *c; |
235 | } | 232 | } |
236 | } | 233 | } |
237 | 234 | ||
238 | *p='\0'; | 235 | *p='\0'; |
239 | 236 | ||
240 | return value; | 237 | return value; |
241 | 238 | ||
242 | } | 239 | } |
243 | 240 | ||
244 | char *mime_headers[] = { | 241 | static char *mime_headers[] = { |
245 | "Content-Type", | 242 | "Content-Type", |
246 | "Content-Transfer-Encoding", | 243 | "Content-Transfer-Encoding", |
247 | "Content-Disposition", | 244 | "Content-Disposition", |
248 | "Content-Id", | 245 | "Content-Id", |
249 | "Mime-Version", | 246 | "Mime-Version", |
250 | 0 | 247 | 0 |
251 | }; | 248 | }; |
252 | 249 | ||
253 | 250 | ||
254 | void* sspm_default_new_part() | 251 | void* sspm_default_new_part() |
255 | { | 252 | { |
256 | return 0; | 253 | return 0; |
257 | } | 254 | } |
258 | void sspm_default_add_line(void *part, struct sspm_header *header, | 255 | void sspm_default_add_line(void *part, struct sspm_header *header, |
259 | char* line, size_t size) | 256 | char* line, size_t size) |
260 | { | 257 | { |
261 | } | 258 | } |
262 | 259 | ||
263 | void* sspm_default_end_part(void* part) | 260 | void* sspm_default_end_part(void* part) |
264 | { | 261 | { |
265 | return 0; | 262 | return 0; |
266 | } | 263 | } |
267 | 264 | ||
268 | void sspm_default_free_part(void *part) | 265 | void sspm_default_free_part(void *part) |
269 | { | 266 | { |
270 | } | 267 | } |
271 | 268 | ||
272 | 269 | ||
273 | 270 | ||
274 | struct sspm_action_map sspm_action_map[] = | 271 | struct sspm_action_map sspm_action_map[] = |
275 | { | 272 | { |
276 | {SSPM_UNKNOWN_MAJOR_TYPE,SSPM_UNKNOWN_MINOR_TYPE,sspm_default_new_part,sspm_default_add_line,sspm_default_end_part,sspm_default_free_part}, | 273 | {SSPM_UNKNOWN_MAJOR_TYPE,SSPM_UNKNOWN_MINOR_TYPE,sspm_default_new_part,sspm_default_add_line,sspm_default_end_part,sspm_default_free_part}, |
277 | }; | 274 | }; |
278 | 275 | ||
279 | int sspm_is_mime_header(char *line) | 276 | int sspm_is_mime_header(char *line) |
280 | { | 277 | { |
281 | char *name = sspm_property_name(line); | 278 | char *name = sspm_property_name(line); |
282 | int i; | 279 | int i; |
283 | 280 | ||
284 | if(name == 0){ | 281 | if(name == 0){ |
285 | return 0; | 282 | return 0; |
286 | } | 283 | } |
287 | 284 | ||
288 | for(i = 0; mime_headers[i] != 0; i++){ | 285 | for(i = 0; mime_headers[i] != 0; i++){ |
289 | if(strcasecmp(name, mime_headers[i]) == 0) | 286 | if(strcasecmp(name, mime_headers[i]) == 0) |
290 | return 1; | 287 | return 1; |
291 | } | 288 | } |
292 | 289 | ||
@@ -321,121 +318,121 @@ int sspm_is_blank(char* line) | |||
321 | } | 318 | } |
322 | 319 | ||
323 | return 0; | 320 | return 0; |
324 | 321 | ||
325 | } | 322 | } |
326 | 323 | ||
327 | int sspm_is_continuation_line(char* line) | 324 | int sspm_is_continuation_line(char* line) |
328 | { | 325 | { |
329 | if (line[0] == ' '|| line[0] == '\t' ) { | 326 | if (line[0] == ' '|| line[0] == '\t' ) { |
330 | return 1; | 327 | return 1; |
331 | } | 328 | } |
332 | 329 | ||
333 | return 0; | 330 | return 0; |
334 | } | 331 | } |
335 | 332 | ||
336 | int sspm_is_mime_boundary(char *line) | 333 | int sspm_is_mime_boundary(char *line) |
337 | { | 334 | { |
338 | if( line[0] == '-' && line[1] == '-') { | 335 | if( line[0] == '-' && line[1] == '-') { |
339 | return 1; | 336 | return 1; |
340 | } | 337 | } |
341 | 338 | ||
342 | return 0; | 339 | return 0; |
343 | } | 340 | } |
344 | 341 | ||
345 | int sspm_is_mime_terminating_boundary(char *line) | 342 | int sspm_is_mime_terminating_boundary(char *line) |
346 | { | 343 | { |
347 | 344 | ||
348 | 345 | ||
349 | if (sspm_is_mime_boundary(line) && | 346 | if (sspm_is_mime_boundary(line) && |
350 | strstr(line,"--\n")){ | 347 | strstr(line,"--\n")){ |
351 | return 1; | 348 | return 1; |
352 | } | 349 | } |
353 | 350 | ||
354 | return 0; | 351 | return 0; |
355 | } | 352 | } |
356 | 353 | ||
357 | enum line_type { | 354 | enum line_type { |
358 | EMPTY, | 355 | EMPTY, |
359 | BLANK, | 356 | BLANK, |
360 | MIME_HEADER, | 357 | MIME_HEADER, |
361 | MAIL_HEADER, | 358 | MAIL_HEADER, |
362 | HEADER_CONTINUATION, | 359 | HEADER_CONTINUATION, |
363 | BOUNDARY, | 360 | BOUNDARY, |
364 | TERMINATING_BOUNDARY, | 361 | TERMINATING_BOUNDARY, |
365 | UNKNOWN_TYPE | 362 | UNKNOWN_TYPE |
366 | }; | 363 | }; |
367 | 364 | ||
368 | 365 | ||
369 | enum line_type get_line_type(char* line){ | 366 | static enum line_type get_line_type(char* line){ |
370 | 367 | ||
371 | if (line == 0){ | 368 | if (line == 0){ |
372 | return EMPTY; | 369 | return EMPTY; |
373 | } else if(sspm_is_blank(line)){ | 370 | } else if(sspm_is_blank(line)){ |
374 | return BLANK; | 371 | return BLANK; |
375 | } else if (sspm_is_mime_header(line)){ | 372 | } else if (sspm_is_mime_header(line)){ |
376 | return MIME_HEADER; | 373 | return MIME_HEADER; |
377 | } else if (sspm_is_mail_header(line)){ | 374 | } else if (sspm_is_mail_header(line)){ |
378 | return MAIL_HEADER; | 375 | return MAIL_HEADER; |
379 | } else if (sspm_is_continuation_line(line)){ | 376 | } else if (sspm_is_continuation_line(line)){ |
380 | return HEADER_CONTINUATION; | 377 | return HEADER_CONTINUATION; |
381 | } else if (sspm_is_mime_terminating_boundary(line)){ | 378 | } else if (sspm_is_mime_terminating_boundary(line)){ |
382 | return TERMINATING_BOUNDARY; | 379 | return TERMINATING_BOUNDARY; |
383 | } else if (sspm_is_mime_boundary(line)) { | 380 | } else if (sspm_is_mime_boundary(line)) { |
384 | return BOUNDARY; | 381 | return BOUNDARY; |
385 | } else { | 382 | } else { |
386 | return UNKNOWN_TYPE; | 383 | return UNKNOWN_TYPE; |
387 | } | 384 | } |
388 | 385 | ||
389 | 386 | ||
390 | } | 387 | } |
391 | 388 | ||
392 | 389 | ||
393 | struct sspm_action_map get_action(struct mime_impl *impl, | 390 | static struct sspm_action_map get_action(struct mime_impl *impl, |
394 | enum sspm_major_type major, | 391 | enum sspm_major_type major, |
395 | enum sspm_minor_type minor) | 392 | enum sspm_minor_type minor) |
396 | { | 393 | { |
397 | int i; | 394 | int i; |
398 | 395 | ||
399 | /* Read caller suppled action map */ | 396 | /* Read caller suppled action map */ |
400 | 397 | ||
401 | if (impl->actions != 0){ | 398 | if (impl->actions != 0){ |
402 | for(i=0; impl->actions[i].major != SSPM_UNKNOWN_MAJOR_TYPE; i++){ | 399 | for(i=0; impl->actions[i].major != SSPM_UNKNOWN_MAJOR_TYPE; i++){ |
403 | if((major == impl->actions[i].major && | 400 | if((major == impl->actions[i].major && |
404 | minor == impl->actions[i].minor) || | 401 | minor == impl->actions[i].minor) || |
405 | (major == impl->actions[i].major && | 402 | (major == impl->actions[i].major && |
406 | minor == SSPM_ANY_MINOR_TYPE)){ | 403 | minor == SSPM_ANY_MINOR_TYPE)){ |
407 | return impl->actions[i]; | 404 | return impl->actions[i]; |
408 | } | 405 | } |
409 | } | 406 | } |
410 | } | 407 | } |
411 | 408 | ||
412 | /* Else, read default action map */ | 409 | /* Else, read default action map */ |
413 | 410 | ||
414 | for(i=0; sspm_action_map[i].major != SSPM_UNKNOWN_MAJOR_TYPE; i++){ | 411 | for(i=0; sspm_action_map[i].major != SSPM_UNKNOWN_MAJOR_TYPE; i++){ |
415 | if((major == sspm_action_map[i].major && | 412 | if((major == sspm_action_map[i].major && |
416 | minor == sspm_action_map[i].minor) || | 413 | minor == sspm_action_map[i].minor) || |
417 | (major == sspm_action_map[i].major && | 414 | (major == sspm_action_map[i].major && |
418 | minor == SSPM_ANY_MINOR_TYPE)){ | 415 | minor == SSPM_ANY_MINOR_TYPE)){ |
419 | break; | 416 | break; |
420 | } | 417 | } |
421 | } | 418 | } |
422 | 419 | ||
423 | return sspm_action_map[i]; | 420 | return sspm_action_map[i]; |
424 | } | 421 | } |
425 | 422 | ||
426 | 423 | ||
427 | char* sspm_lowercase(char* str) | 424 | char* sspm_lowercase(char* str) |
428 | { | 425 | { |
429 | char* p = 0; | 426 | char* p = 0; |
430 | char* new = sspm_strdup(str); | 427 | char* new = sspm_strdup(str); |
431 | 428 | ||
432 | if(str ==0){ | 429 | if(str ==0){ |
433 | return 0; | 430 | return 0; |
434 | } | 431 | } |
435 | 432 | ||
436 | for(p = new; *p!=0; p++){ | 433 | for(p = new; *p!=0; p++){ |
437 | *p = tolower(*p); | 434 | *p = tolower(*p); |
438 | } | 435 | } |
439 | 436 | ||
440 | return new; | 437 | return new; |
441 | } | 438 | } |