… | |
… | |
308 | path = path_combine (src, dst); |
308 | path = path_combine (src, dst); |
309 | path_normalize (path); |
309 | path_normalize (path); |
310 | return (path); |
310 | return (path); |
311 | } |
311 | } |
312 | |
312 | |
313 | /** |
|
|
314 | * open_and_uncompress() first searches for the original filename. If it exist, |
|
|
315 | * then it opens it and returns the file-pointer. |
|
|
316 | */ |
|
|
317 | FILE * |
|
|
318 | open_and_uncompress (const char *name, int flag, int *compressed) |
|
|
319 | { |
|
|
320 | *compressed = 0; |
|
|
321 | return fopen (name, "r"); |
|
|
322 | } |
|
|
323 | |
|
|
324 | /* |
|
|
325 | * See open_and_uncompress(). |
|
|
326 | */ |
|
|
327 | |
|
|
328 | void |
|
|
329 | close_and_delete (FILE * fp, int compressed) |
|
|
330 | { |
|
|
331 | fclose (fp); |
|
|
332 | } |
|
|
333 | |
|
|
334 | /* |
|
|
335 | * Strip out the media tags from a String. |
|
|
336 | * Warning the input string will contain the result string |
|
|
337 | */ |
|
|
338 | void |
|
|
339 | strip_media_tag (char *message) |
|
|
340 | { |
|
|
341 | int in_tag = 0; |
|
|
342 | char *dest; |
|
|
343 | char *src; |
|
|
344 | |
|
|
345 | src = dest = message; |
|
|
346 | while (*src != '\0') |
|
|
347 | { |
|
|
348 | if (*src == '[') |
|
|
349 | { |
|
|
350 | in_tag = 1; |
|
|
351 | } |
|
|
352 | else if (in_tag && (*src == ']')) |
|
|
353 | in_tag = 0; |
|
|
354 | else if (!in_tag) |
|
|
355 | { |
|
|
356 | *dest = *src; |
|
|
357 | dest++; |
|
|
358 | } |
|
|
359 | src++; |
|
|
360 | } |
|
|
361 | *dest = '\0'; |
|
|
362 | } |
|
|
363 | |
|
|
364 | #define EOL_SIZE (sizeof("\n")-1) |
313 | #define EOL_SIZE (sizeof("\n")-1) |
365 | void |
314 | void |
366 | strip_endline (char *buf) |
315 | strip_endline (char *buf) |
367 | { |
316 | { |
368 | if (strlen (buf) < sizeof ("\n")) |
317 | if (*buf && buf [strlen (buf) - 1] == '\n') |
369 | { |
|
|
370 | return; |
|
|
371 | } |
|
|
372 | if (!strcmp (buf + strlen (buf) - EOL_SIZE, "\n")) |
|
|
373 | buf[strlen (buf) - EOL_SIZE] = '\0'; |
318 | buf [strlen (buf) - 1] = '\0'; |
374 | } |
319 | } |
375 | |
320 | |
376 | /** |
321 | /** |
377 | * Replace in string src all occurrences of key by replacement. The resulting |
322 | * Replace in string src all occurrences of key by replacement. The resulting |
378 | * string is put into result; at most resultsize characters (including the |
323 | * string is put into result; at most resultsize characters (including the |