| 1 |
/* ffdummies.c |
| 2 |
|
| 3 |
Copyright 2006-2009 Taco Hoekwater <[email protected]> |
| 4 |
|
| 5 |
This file is part of LuaTeX. |
| 6 |
|
| 7 |
LuaTeX is free software; you can redistribute it and/or modify it under |
| 8 |
the terms of the GNU General Public License as published by the Free |
| 9 |
Software Foundation; either version 2 of the License, or (at your |
| 10 |
option) any later version. |
| 11 |
|
| 12 |
LuaTeX is distributed in the hope that it will be useful, but WITHOUT |
| 13 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 15 |
License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License along |
| 18 |
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ |
| 19 |
|
| 20 |
/* some dummy functions and variables so that a few ff source files can be ignored */ |
| 21 |
|
| 22 |
#include "ffdummies.h" |
| 23 |
|
| 24 |
#include <stdarg.h> |
| 25 |
|
| 26 |
char **gww_errors = NULL; |
| 27 |
int gww_error_count = 0; |
| 28 |
|
| 29 |
void gwwv_errors_free(void) |
| 30 |
{ |
| 31 |
int i; |
| 32 |
if (gww_error_count > 0) { |
| 33 |
for (i = 0; i < gww_error_count; i++) { |
| 34 |
free(gww_errors[i]); |
| 35 |
} |
| 36 |
free(gww_errors); |
| 37 |
gww_error_count = 0; |
| 38 |
gww_errors = NULL; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
__attribute__ ((format(printf, 1, 0))) |
| 43 |
static void LUAUI_IError(const char *format, ...) |
| 44 |
{ |
| 45 |
va_list ap; |
| 46 |
size_t l; |
| 47 |
char buffer[400], *str; |
| 48 |
l = strlen("Internal Error: "); |
| 49 |
snprintf(buffer, sizeof(buffer), "Internal Error: "); |
| 50 |
va_start(ap, format); |
| 51 |
vsnprintf(buffer + l, sizeof(buffer) - l, format, ap); |
| 52 |
va_end(ap); |
| 53 |
str = xstrdup((char *) buffer); |
| 54 |
gww_errors = realloc(gww_errors, (gww_error_count + 2) * sizeof(char *)); |
| 55 |
if (gww_errors == NULL) { |
| 56 |
perror("memory allocation failed"); |
| 57 |
exit(EXIT_FAILURE); |
| 58 |
} |
| 59 |
gww_errors[gww_error_count] = str; |
| 60 |
gww_error_count++; |
| 61 |
gww_errors[gww_error_count] = NULL; |
| 62 |
} |
| 63 |
|
| 64 |
__attribute__ ((format(printf, 1, 0))) |
| 65 |
static void LUAUI__LogError(const char *format, va_list ap) |
| 66 |
{ |
| 67 |
char buffer[400], *str; |
| 68 |
vsnprintf(buffer, sizeof(buffer), format, ap); |
| 69 |
str = xstrdup((char *) buffer); |
| 70 |
gww_errors = realloc(gww_errors, (gww_error_count + 2) * sizeof(char *)); |
| 71 |
if (gww_errors == NULL) { |
| 72 |
perror("memory allocation failed"); |
| 73 |
exit(EXIT_FAILURE); |
| 74 |
} |
| 75 |
gww_errors[gww_error_count] = str; |
| 76 |
gww_error_count++; |
| 77 |
gww_errors[gww_error_count] = NULL; |
| 78 |
} |
| 79 |
|
| 80 |
/* this is not static because it is used by gwwiconv.c */ |
| 81 |
|
| 82 |
__attribute__ ((format(printf, 1, 2))) |
| 83 |
static void LUAUI_LogError(const char *format, ...) |
| 84 |
{ |
| 85 |
va_list ap; |
| 86 |
va_start(ap, format); |
| 87 |
LUAUI__LogError(format, ap); |
| 88 |
va_end(ap); |
| 89 |
} |
| 90 |
|
| 91 |
__attribute__ ((format(printf, 2, 3))) |
| 92 |
static void LUAUI_post_notice(const char *title, const char *statement, ...) |
| 93 |
{ |
| 94 |
va_list ap; |
| 95 |
(void) title; |
| 96 |
va_start(ap, statement); |
| 97 |
LUAUI__LogError(statement, ap); |
| 98 |
va_end(ap); |
| 99 |
} |
| 100 |
|
| 101 |
__attribute__ ((format(printf, 2, 3))) |
| 102 |
static void LUAUI_post_error(const char *title, const char *statement, ...) |
| 103 |
{ |
| 104 |
va_list ap; |
| 105 |
(void) title; |
| 106 |
va_start(ap, statement); |
| 107 |
LUAUI__LogError(statement, ap); |
| 108 |
va_end(ap); |
| 109 |
} |
| 110 |
|
| 111 |
static int LUAUI_ask(const char *title, const char **answers, |
| 112 |
int def, int cancel, const char *question, ...) |
| 113 |
{ |
| 114 |
(void) title; |
| 115 |
(void) answers; |
| 116 |
(void) cancel; |
| 117 |
(void) question; |
| 118 |
return (def); |
| 119 |
} |
| 120 |
|
| 121 |
static int LUAUI_choose(const char *title, const char **choices, int cnt, |
| 122 |
int def, const char *question, ...) |
| 123 |
{ |
| 124 |
(void) title; |
| 125 |
(void) choices; |
| 126 |
(void) cnt; |
| 127 |
(void) question; |
| 128 |
return (def); |
| 129 |
} |
| 130 |
|
| 131 |
static int LUAUI_choose_multiple(char *title, const char **choices, char *sel, |
| 132 |
int cnt, char *buts[2], const char *question, |
| 133 |
...) |
| 134 |
{ |
| 135 |
(void) title; |
| 136 |
(void) choices; |
| 137 |
(void) sel; |
| 138 |
(void) cnt; |
| 139 |
(void) buts; |
| 140 |
(void) question; |
| 141 |
return (-1); |
| 142 |
} |
| 143 |
|
| 144 |
static char *LUAUI_ask_string(const char *title, const char *def, |
| 145 |
const char *question, ...) |
| 146 |
{ |
| 147 |
(void) title; |
| 148 |
(void) def; |
| 149 |
(void) question; |
| 150 |
return def ? strdup(def) : NULL; |
| 151 |
} |
| 152 |
|
| 153 |
static char *LUAUI_open_file(const char *title, const char *defaultfile, |
| 154 |
const char *initial_filter) |
| 155 |
{ |
| 156 |
(void) title; |
| 157 |
(void) initial_filter; |
| 158 |
(void) defaultfile; |
| 159 |
return (NULL); |
| 160 |
} |
| 161 |
|
| 162 |
static char *LUAUI_saveas_file(const char *title, const char *defaultfile, |
| 163 |
const char *initial_filter) |
| 164 |
{ |
| 165 |
(void) title; |
| 166 |
(void) initial_filter; |
| 167 |
return (copy(defaultfile)); |
| 168 |
} |
| 169 |
|
| 170 |
static void LUAUI_progress_start(int delay, const char *title, |
| 171 |
const char *line1, const char *line2, int tot, |
| 172 |
int stages) |
| 173 |
{ |
| 174 |
(void) delay; |
| 175 |
(void) title; |
| 176 |
(void) line1; |
| 177 |
(void) line2; |
| 178 |
(void) tot; |
| 179 |
(void) stages; |
| 180 |
} |
| 181 |
|
| 182 |
static void LUAUI_void_void_noop(void) |
| 183 |
{ |
| 184 |
} |
| 185 |
|
| 186 |
static void LUAUI_void_int_noop(int useless) |
| 187 |
{ |
| 188 |
(void) useless; |
| 189 |
} |
| 190 |
|
| 191 |
static int LUAUI_int_int_noop(int useless) |
| 192 |
{ |
| 193 |
(void) useless; |
| 194 |
return (true); |
| 195 |
} |
| 196 |
|
| 197 |
static void LUAUI_void_str_noop(const char *useless) |
| 198 |
{ |
| 199 |
(void) useless; |
| 200 |
} |
| 201 |
|
| 202 |
static int LUAUI_alwaystrue(void) |
| 203 |
{ |
| 204 |
return (true); |
| 205 |
} |
| 206 |
|
| 207 |
static int LUAUI_DefaultStrokeFlags(void) |
| 208 |
{ |
| 209 |
return (sf_correctdir); |
| 210 |
} |
| 211 |
|
| 212 |
struct ui_interface luaui_interface = { |
| 213 |
LUAUI_IError, |
| 214 |
LUAUI_post_error, |
| 215 |
LUAUI_LogError, |
| 216 |
LUAUI_post_notice, |
| 217 |
LUAUI_ask, |
| 218 |
LUAUI_choose, |
| 219 |
LUAUI_choose_multiple, |
| 220 |
LUAUI_ask_string, |
| 221 |
LUAUI_ask_string, /* password */ |
| 222 |
LUAUI_open_file, |
| 223 |
LUAUI_saveas_file, |
| 224 |
|
| 225 |
LUAUI_progress_start, |
| 226 |
LUAUI_void_void_noop, |
| 227 |
LUAUI_void_void_noop, |
| 228 |
LUAUI_void_int_noop, |
| 229 |
LUAUI_alwaystrue, |
| 230 |
LUAUI_alwaystrue, |
| 231 |
LUAUI_int_int_noop, |
| 232 |
LUAUI_void_str_noop, |
| 233 |
LUAUI_void_str_noop, |
| 234 |
LUAUI_void_void_noop, |
| 235 |
LUAUI_void_void_noop, |
| 236 |
LUAUI_void_int_noop, |
| 237 |
LUAUI_void_int_noop, |
| 238 |
LUAUI_alwaystrue, |
| 239 |
|
| 240 |
LUAUI_void_void_noop, |
| 241 |
|
| 242 |
NOUI_TTFNameIds, |
| 243 |
NOUI_MSLangString, |
| 244 |
|
| 245 |
LUAUI_DefaultStrokeFlags |
| 246 |
}; |
| 247 |
|
| 248 |
/* some bits and pieces */ |
| 249 |
|
| 250 |
int URLFromFile(char *url, FILE * from) |
| 251 |
{ |
| 252 |
(void) url; |
| 253 |
(void) from; |
| 254 |
return false; |
| 255 |
} |
| 256 |
|
| 257 |
/* print.c */ |
| 258 |
int pagewidth = 0, pageheight = 0; /* In points */ |
| 259 |
char *printlazyprinter = NULL; |
| 260 |
char *printcommand = NULL; |
| 261 |
int printtype = 0; |
| 262 |
|
| 263 |
void ScriptPrint(FontViewBase * fv, int type, int32 * pointsizes, |
| 264 |
char *samplefile, unichar_t * sample, char *outputfile) |
| 265 |
{ |
| 266 |
(void) fv; |
| 267 |
(void) type; |
| 268 |
(void) pointsizes; |
| 269 |
(void) samplefile; |
| 270 |
(void) sample; |
| 271 |
(void) outputfile; |
| 272 |
} |
| 273 |
|
| 274 |
#if 0 /* unused */ |
| 275 |
static int PdfDumpGlyphResources(void *pi, SplineChar * sc) |
| 276 |
{ |
| 277 |
(void) pi; |
| 278 |
(void) sc; |
| 279 |
return 0; |
| 280 |
} |
| 281 |
#endif |
| 282 |
|
| 283 |
/* autotrace.c */ |
| 284 |
int autotrace_ask = 0, mf_ask = 0, mf_clearbackgrounds = 0, mf_showerrors = 0; |
| 285 |
char *mf_args = NULL; |
| 286 |
int preferpotrace = 0; |
| 287 |
|
| 288 |
void *GetAutoTraceArgs(void) |
| 289 |
{ |
| 290 |
return NULL; |
| 291 |
} |
| 292 |
|
| 293 |
void SetAutoTraceArgs(void *a) |
| 294 |
{ |
| 295 |
(void) a; |
| 296 |
} |
| 297 |
|
| 298 |
void FVAutoTrace(FontViewBase * fv, int ask) |
| 299 |
{ |
| 300 |
(void) fv; |
| 301 |
(void) ask; |
| 302 |
} |
| 303 |
|
| 304 |
SplineFont *SFFromMF(char *filename) |
| 305 |
{ |
| 306 |
(void) filename; |
| 307 |
return NULL; |
| 308 |
} |
| 309 |
|
| 310 |
/* http.c */ |
| 311 |
|
| 312 |
FILE *URLToTempFile(char *url, void *_lock) |
| 313 |
{ |
| 314 |
(void) _lock; |
| 315 |
(void) url; |
| 316 |
ff_post_error(_("Could not parse URL"), |
| 317 |
_("FontForge only handles ftp and http URLs at the moment")); |
| 318 |
return (NULL); |
| 319 |
} |