1 | /* |
1 | /* |
2 | parse_aux.c - Part of psiconv, a PSION 5 file formats converter |
2 | parse_aux.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl> |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
… | |
… | |
20 | #include "config.h" |
20 | #include "config.h" |
21 | #include "compat.h" |
21 | #include "compat.h" |
22 | #include <stdarg.h> |
22 | #include <stdarg.h> |
23 | #include <stdio.h> |
23 | #include <stdio.h> |
24 | #include <stdlib.h> |
24 | #include <stdlib.h> |
|
|
25 | #include <string.h> |
25 | #include "common.h" |
26 | #include "common.h" |
26 | |
27 | |
27 | #ifdef DMALLOC |
28 | #ifdef DMALLOC |
28 | #include <dmalloc.h> |
29 | #include <dmalloc.h> |
29 | #endif |
30 | #endif |
30 | |
31 | |
31 | |
32 | |
32 | char *psiconv_make_printable(const char *s) |
33 | char *psiconv_make_printable(const psiconv_config config, |
|
|
34 | const psiconv_string_t input) |
33 | { |
35 | { |
34 | int i; |
36 | int i; |
35 | char *res = malloc(strlen(s) + 1); |
37 | char *output; |
36 | if (!res) |
38 | |
|
|
39 | if (!(output = malloc(sizeof(*output) * |
|
|
40 | (psiconv_unicode_strlen(input) + 1)))) { |
37 | return NULL; |
41 | return NULL; |
|
|
42 | } |
|
|
43 | |
38 | for (i = 0; i < strlen(s); i ++) |
44 | for (i = 0; i < psiconv_unicode_strlen(input); i ++) |
39 | if (s[i] < 0x20 || s[i] >= 0x7f) |
45 | if (input[i] < 0x20 || input[i] >= 0x7f) |
40 | res[i] = '.'; |
46 | output[i] = '.'; |
41 | else |
47 | else |
42 | res[i] = s[i]; |
48 | output[i] = input[i]; |
43 | res[strlen(s)] = 0; |
49 | input[i] = 0; |
44 | return res; |
50 | return output; |
45 | } |
51 | } |