Debian Codegraph @

fontforge/nouiutil.c

raw symbols SCIP
1 /* Copyright (C) 2000-2012 by George Williams */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
8
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #include <fontforge-config.h>
29
30 #include "basics.h"
31 #include "splinefont.h"
32 #include "uiinterface.h"
33 #include "ustring.h"
34
35 #include <stdarg.h>
36 #include <stdio.h>
37
38 static void NOUI_IError(const char *format,...) {
39 va_list ap;
40 char buffer[400], *str;
41 va_start(ap,format);
42 fprintf(stderr, "Internal Error: " );
43 vsnprintf(buffer,sizeof(buffer),format,ap);
44 str = utf82def_copy_safe(buffer);
45 fprintf(stderr,"%s",str);
46 if ( str[strlen(str)-1]!='\n' )
47 putc('\n',stderr);
48 free(str);
49 va_end(ap);
50 }
51
52 static void NOUI__LogError(const char *format,va_list ap) {
53 char buffer[400], *str;
54 vsnprintf(buffer,sizeof(buffer),format,ap);
55 str = utf82def_copy_safe(buffer);
56 fprintf(stderr,"%s",str);
57 if ( str[strlen(str)-1]!='\n' )
58 putc('\n',stderr);
59 free(str);
60 }
61
62 static void NOUI_LogError(const char *format,...) {
63 va_list ap;
64
65 va_start(ap,format);
66 NOUI__LogError(format,ap);
67 va_end(ap);
68 }
69
70 static void NOUI_post_notice(const char *title,const char *statement,...) {
71 va_list ap;
72 va_start(ap,statement);
73 NOUI__LogError(statement,ap);
74 va_end(ap);
75 }
76
77 static void NOUI_post_error(const char *title,const char *statement,...) {
78 va_list ap;
79 va_start(ap,statement);
80 NOUI__LogError(statement,ap);
81 va_end(ap);
82 }
83
84 static int NOUI_ask(const char *title, const char **answers,
85 int def, int cancel,const char *question,...) {
86 return( def );
87 }
88
89 static int NOUI_choose(const char *title, const char **choices,int cnt, int def,
90 const char *question,...) {
91 return( def );
92 }
93
94 static int NOUI_choose_multiple(const char *title, const char **choices, char *sel,
95 int cnt, char *buts[2], const char *question,...) {
96 return( -1 );
97 }
98
99 static char *NOUI_ask_string(const char *title, const char *def,
100 const char *question,...) {
101 return( (char *) def );
102 }
103
104 static char *NOUI_open_file(const char *title, const char *defaultfile,
105 const char *initial_filter) {
106 return( NULL );
107 }
108
109 static char *NOUI_saveas_file(const char *title, const char *defaultfile,
110 const char *initial_filter) {
111 return( copy(defaultfile) );
112 }
113
114 static void NOUI_progress_start(int delay, const char *title, const char *line1,
115 const char *line2, int tot, int stages) {
116 }
117
118 static void NOUI_void_void_noop(void) {
119 }
120
121 static void NOUI_void_int_noop(int useless) {
122 }
123
124 static int NOUI_int_int_noop(int useless) {
125 return( true );
126 }
127
128 static void NOUI_void_str_noop(const char * useless) {
129 }
130
131 static int NOUI_alwaystrue(void) {
132 return( true );
133 }
134
135 static void NOUI_import_params_dlg(struct importparams *ip) {
136 }
137
138 static void NOUI_export_params_dlg(struct exportparams *ep) {
139 }
140
141 #ifndef _NO_PYTHON
142 static void NOUI_plugin_dlg(void) {
143 }
144 #endif
145
146 static int NOUI_ask_multi(const char *title, struct multi_dlg_spec *spec) {
147 return false;
148 }
149
150 static struct ui_interface noui_interface = {
151 NOUI_IError,
152 NOUI_post_error,
153 NOUI_LogError,
154 NOUI_post_notice,
155 NOUI_ask,
156 NOUI_choose,
157 NOUI_choose_multiple,
158 NOUI_ask_string,
159 NOUI_ask_string, /* password */
160 NOUI_open_file,
161 NOUI_saveas_file,
162
163 NOUI_progress_start,
164 NOUI_void_void_noop,
165 NOUI_void_void_noop,
166 NOUI_void_int_noop,
167 NOUI_alwaystrue,
168 NOUI_alwaystrue,
169 NOUI_int_int_noop,
170 NOUI_void_str_noop,
171 NOUI_void_str_noop,
172 NOUI_void_void_noop,
173 NOUI_void_void_noop,
174 NOUI_void_int_noop,
175 NOUI_void_int_noop,
176 NOUI_alwaystrue,
177
178 NOUI_void_void_noop,
179
180 NOUI_TTFNameIds,
181 NOUI_MSLangString,
182 NOUI_import_params_dlg,
183 NOUI_export_params_dlg,
184 #ifndef _NO_PYTHON
185 NOUI_plugin_dlg,
186 #endif
187 NOUI_ask_multi
188 };
189 struct ui_interface *ui_interface = &noui_interface;
190
191 void FF_SetUiInterface(struct ui_interface *uii) {
192 ui_interface = uii;
193 }