1 | /* |
1 | /* |
2 | magick-aux.c - Part of psiconv, a PSION 5 file formats converter |
2 | magick-aux.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 2000-2005 Frodo Looijaard <frodo@frodo.looijaard.name> |
3 | Copyright (c) 2000-2014 Frodo Looijaard <frodo@frodo.looijaard.name> |
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. |
… | |
… | |
32 | #if IMAGEMAGICK |
32 | #if IMAGEMAGICK |
33 | |
33 | |
34 | /* This used to be very ugly, but nowadays it is much better */ |
34 | /* This used to be very ugly, but nowadays it is much better */ |
35 | |
35 | |
36 | #if IMAGEMAGICK_API == 1 || IMAGEMAGICK_API == 2 |
36 | #if IMAGEMAGICK_API == 1 || IMAGEMAGICK_API == 2 |
37 | const MagickInfo * GetMagickFileList(void) |
37 | const MagickInfo ** GetMagickFileList(void) |
38 | { |
38 | { |
|
|
39 | int len,i; |
|
|
40 | const MagickInfo *ptr; |
|
|
41 | const MagickInfo *mi_ptr; |
|
|
42 | const MagickInfo **copy; |
39 | ExceptionInfo exc; |
43 | ExceptionInfo exc; |
40 | GetExceptionInfo(&exc); |
44 | GetExceptionInfo(&exc); |
41 | OpenModules(&exc); |
45 | OpenModules(&exc); |
|
|
46 | |
42 | return GetMagickInfo(NULL,&exc); |
47 | mi_ptr = GetMagickInfo(NULL,&exc); |
|
|
48 | for (len = 0, ptr=mi_ptr; ptr != NULL; len++, ptr = ptr->next); |
|
|
49 | copy = malloc((len+1) * sizeof(*copy)); |
|
|
50 | for (i=0, ptr=mi_ptr; ptr != NULL; i++, ptr = ptr->next) |
|
|
51 | copy[i] = ptr; |
|
|
52 | copy[len] = NULL; |
|
|
53 | return copy; |
43 | } |
54 | } |
44 | |
55 | |
45 | #elif IMAGEMAGICK_API == 3 |
56 | #elif IMAGEMAGICK_API == 3 |
46 | |
57 | |
47 | const MagickInfo * GetMagickFileList(void) |
58 | const MagickInfo ** GetMagickFileList(void) |
48 | { |
59 | { |
49 | MagickInfo **mi; |
60 | MagickInfo **mi; |
|
|
61 | const MagickInfo **copy; |
50 | unsigned long nr; |
62 | unsigned long len; |
51 | int i; |
63 | int i; |
52 | ExceptionInfo exc; |
64 | ExceptionInfo exc; |
53 | GetExceptionInfo(&exc); |
65 | GetExceptionInfo(&exc); |
54 | OpenModules(&exc); |
66 | OpenModules(&exc); |
55 | mi = GetMagickInfoList("*",&nr); |
67 | mi = GetMagickInfoList("*",&len); |
|
|
68 | copy = malloc((len+1) * sizeof(*copy)); |
56 | for (i = 0; i < nr-1; i++) { |
69 | for (i = 0; i < len; i++) { |
57 | mi[i]->next = mi[i+1]; |
70 | copy[i] = mi[i]; |
58 | } |
71 | } |
59 | return *mi; |
72 | copy[len] = NULL; |
|
|
73 | return copy; |
60 | } |
74 | } |
61 | |
75 | |
62 | #elif IMAGEMAGICK_API == 4 |
76 | #elif IMAGEMAGICK_API == 4 |
63 | |
77 | |
64 | const MagickInfo * GetMagickFileList(void) |
78 | const MagickInfo ** GetMagickFileList(void) |
65 | { |
79 | { |
66 | MagickInfo **mi; |
80 | const MagickInfo **mi; |
|
|
81 | const MagickInfo **copy; |
67 | unsigned long nr; |
82 | unsigned long len; |
68 | int i; |
83 | int i; |
69 | ExceptionInfo exc; |
84 | ExceptionInfo exc; |
70 | GetExceptionInfo(&exc); |
85 | GetExceptionInfo(&exc); |
71 | OpenModules(&exc); |
86 | OpenModules(&exc); |
72 | mi = GetMagickInfoList("*",&nr,&exc); |
87 | mi = GetMagickInfoList("*",&len,&exc); |
|
|
88 | copy = malloc((len+1) * sizeof(*copy)); |
73 | for (i = 0; i < nr-1; i++) { |
89 | for (i = 0; i < len; i++) { |
74 | mi[i]->next = mi[i+1]; |
90 | copy[i] = mi[i]; |
75 | } |
91 | } |
76 | return *mi; |
92 | copy[len] = NULL; |
|
|
93 | return copy; |
77 | } |
94 | } |
|
|
95 | |
|
|
96 | #elif IMAGEMAGICK_API == 100 |
|
|
97 | /* GraphicsMagick library */ |
|
|
98 | const MagickInfo ** GetMagickFileList(void) |
|
|
99 | { |
|
|
100 | int i,len; |
|
|
101 | MagickInfo **mi; |
|
|
102 | const MagickInfo **copy; |
|
|
103 | ExceptionInfo exception; |
|
|
104 | GetExceptionInfo(&exception); |
|
|
105 | mi = GetMagickInfoArray(&exception); |
|
|
106 | for (len = 0; mi[len]; len++); |
|
|
107 | copy = malloc((len+1) * sizeof(*copy)); |
|
|
108 | for (i = 0; i <= len; i++) { |
|
|
109 | copy[i] = mi[i]; |
|
|
110 | } |
|
|
111 | return copy; |
|
|
112 | } |
|
|
113 | |
78 | #endif |
114 | #endif |
79 | |
115 | |
80 | #endif /* IMAGEMAGICK */ |
116 | #endif /* IMAGEMAGICK */ |