Commit 43fde31531a8888fc36cf102b6dd3b85f6aaccdb
1 parent
61d7cb90
Exists in
master
and in
3 other branches
Tradução para pt-br, limpeza de códigos não usados
Showing
10 changed files
with
50 additions
and
763 deletions
Show diff stats
Makefile.in
| ... | ... | @@ -103,7 +103,7 @@ $(TMPDIR)/pot/%.pot: %.c |
| 103 | 103 | |
| 104 | 104 | SOURCES = XtGlue.c init.c actions.c ansi.c charset.c ctlr.c \ |
| 105 | 105 | ft.c ft_cut.c ft_dft.c glue.c host.c kybd.c \ |
| 106 | - print.c printer.c proxy.c resources.c rpq.c screen.c see.c \ | |
| 106 | + proxy.c resources.c rpq.c screen.c see.c \ | |
| 107 | 107 | sf.c tables.c telnet.c toggles.c trace_ds.c utf8.c util.c \ |
| 108 | 108 | xio.c resolver.c log.c paste.c macros.c fallbacks.c version.c \ |
| 109 | 109 | selection.c bounds.c | ... | ... |
charset.c
| ... | ... | @@ -101,7 +101,7 @@ static enum cs_result check_charset(void); |
| 101 | 101 | static char *char_if_ascii7(unsigned long l); |
| 102 | 102 | #endif /*]*/ |
| 103 | 103 | |
| 104 | -static void set_cgcsgids(char *spec); | |
| 104 | +static void set_cgcsgids(const char *spec); | |
| 105 | 105 | static int set_cgcsgid(char *spec, unsigned long *idp); |
| 106 | 106 | |
| 107 | 107 | // static void set_charset_name(char *csname); |
| ... | ... | @@ -159,7 +159,7 @@ restore_charset(void) |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /* Get a character set definition. */ |
| 162 | -static char * get_charset_def(const char *csname) | |
| 162 | +static const char * get_charset_def(const char *csname) | |
| 163 | 163 | { |
| 164 | 164 | return get_fresource("%s.%s", ResCharset, csname); |
| 165 | 165 | } |
| ... | ... | @@ -193,7 +193,8 @@ wide_resource_init(char *csname) |
| 193 | 193 | */ |
| 194 | 194 | enum cs_result charset_init(H3270 *session, char *csname) |
| 195 | 195 | { |
| 196 | - char *cs, *ftcs; | |
| 196 | + const char *cs; | |
| 197 | + const char *ftcs; | |
| 197 | 198 | enum cs_result rc; |
| 198 | 199 | char *ccs, *cftcs; |
| 199 | 200 | /* |
| ... | ... | @@ -201,7 +202,7 @@ enum cs_result charset_init(H3270 *session, char *csname) |
| 201 | 202 | char *xks; |
| 202 | 203 | #endif |
| 203 | 204 | */ |
| 204 | - char *ak; | |
| 205 | + const char *ak; | |
| 205 | 206 | |
| 206 | 207 | /* |
| 207 | 208 | #if !defined(_WIN32) |
| ... | ... | @@ -317,8 +318,7 @@ set_cgcsgid(char *spec, unsigned long *r) |
| 317 | 318 | } |
| 318 | 319 | |
| 319 | 320 | /* Set the CGCSGIDs. */ |
| 320 | -static void | |
| 321 | -set_cgcsgids(char *spec) | |
| 321 | +static void set_cgcsgids(const char *spec) | |
| 322 | 322 | { |
| 323 | 323 | int n_ids = 0; |
| 324 | 324 | char *spec_copy; |
| ... | ... | @@ -386,9 +386,9 @@ static enum cs_result resource_charset(char *csname, char *cs, char *ftcs) |
| 386 | 386 | { |
| 387 | 387 | enum cs_result rc; |
| 388 | 388 | int ne = 0; |
| 389 | - char *rcs = CN; | |
| 389 | + const char *rcs = CN; | |
| 390 | 390 | int n_rcs = 0; |
| 391 | - char *dcs; | |
| 391 | + const char *dcs; | |
| 392 | 392 | |
| 393 | 393 | /* Interpret the spec. */ |
| 394 | 394 | rc = remap_chars(csname, cs, (ftcs == NULL)? BOTH: CS_ONLY, &ne); |
| ... | ... | @@ -737,7 +737,7 @@ check_charset(void) |
| 737 | 737 | } |
| 738 | 738 | #endif /*]*/ |
| 739 | 739 | |
| 740 | -void set_display_charset(H3270 *session, char *dcs) | |
| 740 | +void set_display_charset(H3270 *session, const char *dcs) | |
| 741 | 741 | { |
| 742 | 742 | session->charset = strdup(dcs); |
| 743 | 743 | } | ... | ... |
charsetc.h
| ... | ... | @@ -38,5 +38,5 @@ enum cs_result { CS_OKAY, CS_NOTFOUND, CS_BAD, CS_PREREQ, CS_ILLEGAL }; |
| 38 | 38 | LIB3270_INTERNAL enum cs_result charset_init(H3270 *session, char *csname); |
| 39 | 39 | // LIB3270_INTERNAL char *get_charset_name(void); |
| 40 | 40 | |
| 41 | -LIB3270_INTERNAL void set_display_charset(H3270 *session, char *dcs); | |
| 41 | +LIB3270_INTERNAL void set_display_charset(H3270 *session, const char *dcs); | |
| 42 | 42 | ... | ... |
ft_dft.c
| ... | ... | @@ -162,7 +162,7 @@ dft_open_request(unsigned short len, unsigned char *cp) |
| 162 | 162 | GET16(recsz, recszp); |
| 163 | 163 | name = (char *)cp + 31; |
| 164 | 164 | } else { |
| 165 | - dft_abort( _("ftDftUknownOpen"), TR_OPEN_REQ); | |
| 165 | + dft_abort( _("Uknown DFT Open type from host"), TR_OPEN_REQ); | |
| 166 | 166 | return; |
| 167 | 167 | } |
| 168 | 168 | |
| ... | ... | @@ -307,8 +307,7 @@ dft_data_insert(struct data_buffer *data_bufr) |
| 307 | 307 | /* write failed */ |
| 308 | 308 | char *buf; |
| 309 | 309 | |
| 310 | - buf = xs_buffer("write(%s): %s", ft_local_filename, | |
| 311 | - strerror(errno)); | |
| 310 | + buf = xs_buffer( _( "write(%s): %s" ), ft_local_filename,strerror(errno)); | |
| 312 | 311 | |
| 313 | 312 | dft_abort(buf, TR_DATA_INSERT); |
| 314 | 313 | Free(buf); | ... | ... |
init.c
print.c
| ... | ... | @@ -36,722 +36,3 @@ |
| 36 | 36 | */ |
| 37 | 37 | |
| 38 | 38 | #include "globals.h" |
| 39 | - | |
| 40 | -#include "appres.h" | |
| 41 | -#include "3270ds.h" | |
| 42 | -// #include "ctlr.h" | |
| 43 | - | |
| 44 | -#include "ctlrc.h" | |
| 45 | -#include "tablesc.h" | |
| 46 | - | |
| 47 | -#include <errno.h> | |
| 48 | - | |
| 49 | -#if defined(X3270_DISPLAY) /*[*/ | |
| 50 | -#include <X11/StringDefs.h> | |
| 51 | -#include <X11/Xaw/Dialog.h> | |
| 52 | -#endif /*]*/ | |
| 53 | - | |
| 54 | -#include "objects.h" | |
| 55 | -#include "resources.h" | |
| 56 | - | |
| 57 | -#include "actionsc.h" | |
| 58 | -#include "popupsc.h" | |
| 59 | -#include "printc.h" | |
| 60 | -#include "utf8c.h" | |
| 61 | -#include "utilc.h" | |
| 62 | -#if defined(X3270_DBCS) /*[*/ | |
| 63 | -#include "widec.h" | |
| 64 | -#endif /*]*/ | |
| 65 | -#if defined(_WIN32) /*[*/ | |
| 66 | -#include <io.h> | |
| 67 | -#include <fcntl.h> | |
| 68 | -#include <sys/stat.h> | |
| 69 | -#endif /*]*/ | |
| 70 | - | |
| 71 | -#include "api.h" | |
| 72 | - | |
| 73 | -/* Statics */ | |
| 74 | - | |
| 75 | -/* | |
| 76 | -#if defined(X3270_DISPLAY) | |
| 77 | -static Widget print_text_shell = (Widget)NULL; | |
| 78 | -static Widget save_text_shell = (Widget)NULL; | |
| 79 | -static Widget print_window_shell = (Widget)NULL; | |
| 80 | -static char *print_window_command = CN; | |
| 81 | -#endif | |
| 82 | -*/ | |
| 83 | - | |
| 84 | -/* Print Text popup */ | |
| 85 | - | |
| 86 | -/* | |
| 87 | - * Map default 3279 colors. This code is duplicated three times. ;-( | |
| 88 | - */ /* | |
| 89 | -static int | |
| 90 | -color_from_fa(unsigned char fa) | |
| 91 | -{ | |
| 92 | - static int field_colors[4] = { | |
| 93 | - COLOR_GREEN, // default | |
| 94 | - COLOR_RED, // intensified | |
| 95 | - COLOR_BLUE, // protected | |
| 96 | - COLOR_WHITE // protected, intensified | |
| 97 | -# define DEFCOLOR_MAP(f) \ | |
| 98 | - ((((f) & FA_PROTECT) >> 4) | (((f) & FA_INT_HIGH_SEL) >> 3)) | |
| 99 | - }; | |
| 100 | - | |
| 101 | - if (appres.m3279) | |
| 102 | - return field_colors[DEFCOLOR_MAP(fa)]; | |
| 103 | - else | |
| 104 | - return COLOR_GREEN; | |
| 105 | -} | |
| 106 | -*/ | |
| 107 | -/* | |
| 108 | - * Map 3279 colors onto HTML colors. | |
| 109 | - */ /* | |
| 110 | -static char * | |
| 111 | -html_color(int color) | |
| 112 | -{ | |
| 113 | - static char *html_color_map[] = { | |
| 114 | - "black", | |
| 115 | - "deepSkyBlue", | |
| 116 | - "red", | |
| 117 | - "pink", | |
| 118 | - "green", | |
| 119 | - "turquoise", | |
| 120 | - "yellow", | |
| 121 | - "white", | |
| 122 | - "black", | |
| 123 | - "blue3", | |
| 124 | - "orange", | |
| 125 | - "purple", | |
| 126 | - "paleGreen", | |
| 127 | - "paleTurquoise2", | |
| 128 | - "grey", | |
| 129 | - "white" | |
| 130 | - }; | |
| 131 | - if (color >= COLOR_NEUTRAL_BLACK && color <= COLOR_WHITE) | |
| 132 | - return html_color_map[color]; | |
| 133 | - else | |
| 134 | - return "black"; | |
| 135 | -} | |
| 136 | -*/ | |
| 137 | - | |
| 138 | -/* | |
| 139 | - * Print the ASCIIfied contents of the screen onto a stream. | |
| 140 | - * Returns True if anything printed, False otherwise. | |
| 141 | - * | |
| 142 | - * If 'use_html' is True, then HTML is generated, which preserves colors, but | |
| 143 | - * little else (for now). | |
| 144 | - */ | |
| 145 | -Boolean | |
| 146 | -fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) | |
| 147 | -{ | |
| 148 | - return False; | |
| 149 | - | |
| 150 | -/* | |
| 151 | - register int i; | |
| 152 | - char c; | |
| 153 | - int ns = 0; | |
| 154 | - int nr = 0; | |
| 155 | - Boolean any = False; | |
| 156 | - int fa_addr = find_field_attribute(&h3270,0); | |
| 157 | - unsigned char fa = h3270.ea_buf[fa_addr].fa; | |
| 158 | - int fa_color, current_color; | |
| 159 | - Bool fa_high, current_high; | |
| 160 | - | |
| 161 | - if (use_html) { | |
| 162 | - even_if_empty = True; | |
| 163 | - } | |
| 164 | - | |
| 165 | - if (h3270.ea_buf[fa_addr].fg) | |
| 166 | - fa_color = h3270.ea_buf[fa_addr].fg & 0x0f; | |
| 167 | - else | |
| 168 | - fa_color = color_from_fa(fa); | |
| 169 | - current_color = fa_color; | |
| 170 | - | |
| 171 | - if (h3270.ea_buf[fa_addr].gr & GR_INTENSIFY) | |
| 172 | - fa_high = True; | |
| 173 | - else | |
| 174 | - fa_high = FA_IS_HIGH(fa); | |
| 175 | - current_high = fa_high; | |
| 176 | - | |
| 177 | - for (i = 0; i < h3270.rows*h3270.cols; i++) { | |
| 178 | -#if defined(X3270_DBCS) | |
| 179 | - char mb[16]; | |
| 180 | - Boolean is_dbcs = False; | |
| 181 | -#endif | |
| 182 | - | |
| 183 | - if (i && !(i % h3270.cols)) { | |
| 184 | - nr++; | |
| 185 | - ns = 0; | |
| 186 | - } | |
| 187 | - if (h3270.ea_buf[i].fa) { | |
| 188 | - c = ' '; | |
| 189 | - fa = h3270.ea_buf[i].fa; | |
| 190 | - if (h3270.ea_buf[i].fg) | |
| 191 | - fa_color = h3270.ea_buf[i].fg & 0x0f; | |
| 192 | - else | |
| 193 | - fa_color = color_from_fa(fa); | |
| 194 | - if (h3270.ea_buf[i].gr & GR_INTENSIFY) | |
| 195 | - fa_high = True; | |
| 196 | - else | |
| 197 | - fa_high = FA_IS_HIGH(fa); | |
| 198 | - } | |
| 199 | - if (FA_IS_ZERO(fa)) | |
| 200 | - c = ' '; | |
| 201 | -#if defined(X3270_DBCS) | |
| 202 | - else { | |
| 203 | - // XXX: DBCS/html interactions are not done | |
| 204 | - switch (ctlr_dbcs_state(i)) { | |
| 205 | - case DBCS_NONE: | |
| 206 | - case DBCS_SB: | |
| 207 | - c = ebc2asc[ea_buf[i].cc]; | |
| 208 | - break; | |
| 209 | - case DBCS_LEFT: | |
| 210 | - dbcs_to_mb(ea_buf[i].cc, ea_buf[i + 1].cc, mb); | |
| 211 | - is_dbcs = True; | |
| 212 | - c = 'x'; | |
| 213 | - break; | |
| 214 | - default: | |
| 215 | - c = ' '; | |
| 216 | - break; | |
| 217 | - } | |
| 218 | - } | |
| 219 | -#else | |
| 220 | - else | |
| 221 | - c = ebc2asc[h3270.ea_buf[i].cc]; | |
| 222 | -#endif | |
| 223 | - if (c == ' ') | |
| 224 | - ns++; | |
| 225 | - else { | |
| 226 | - while (nr) { | |
| 227 | - (void) fputc('\n', f); | |
| 228 | - nr--; | |
| 229 | - } | |
| 230 | - while (ns) { | |
| 231 | - (void) fputc(' ', f); | |
| 232 | - ns--; | |
| 233 | - } | |
| 234 | - if (use_html) { | |
| 235 | - int color; | |
| 236 | - Bool high; | |
| 237 | - | |
| 238 | - if (h3270.ea_buf[i].fg) | |
| 239 | - color = h3270.ea_buf[i].fg & 0x0f; | |
| 240 | - else | |
| 241 | - color = fa_color; | |
| 242 | - if (color != current_color) { | |
| 243 | - if (any) | |
| 244 | - fprintf(f, "</font><font color=%s>", | |
| 245 | - html_color(color)); | |
| 246 | - current_color = color; | |
| 247 | - } | |
| 248 | - if (h3270.ea_buf[i].gr & GR_INTENSIFY) | |
| 249 | - high = True; | |
| 250 | - else | |
| 251 | - high = fa_high; | |
| 252 | - if (high != current_high) { | |
| 253 | - if (any) { | |
| 254 | - if (high) | |
| 255 | - fprintf(f, "<b>"); | |
| 256 | - else | |
| 257 | - fprintf(f, "</b>"); | |
| 258 | - } | |
| 259 | - current_high = high; | |
| 260 | - } | |
| 261 | - if (!any) { | |
| 262 | - fprintf(f, "<html>\n" | |
| 263 | - "<head>\n" | |
| 264 | - " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n" | |
| 265 | - "</head>\n" | |
| 266 | - " <body>\n" | |
| 267 | - " <table border=0>" | |
| 268 | - "<tr bgcolor=black><td>" | |
| 269 | - "<pre><font color=%s>%s", | |
| 270 | - lib3270_get_charset(&h3270), | |
| 271 | - html_color(current_color), | |
| 272 | - current_high? "<b>": ""); | |
| 273 | - } | |
| 274 | - } | |
| 275 | - any = True; | |
| 276 | -#if defined(X3270_DBCS) | |
| 277 | - if (is_dbcs) { | |
| 278 | - (void) fputs(mb, f); | |
| 279 | - i++; | |
| 280 | - } | |
| 281 | - else | |
| 282 | -#endif | |
| 283 | - { | |
| 284 | - if (use_html && c == '<') | |
| 285 | - fprintf(f, "<"); | |
| 286 | - else | |
| 287 | - (void) fputs(utf8_expand(c), f); | |
| 288 | - } | |
| 289 | - } | |
| 290 | - } | |
| 291 | - nr++; | |
| 292 | - if (!any && !even_if_empty) | |
| 293 | - return False; | |
| 294 | - while (nr) { | |
| 295 | - (void) fputc('\n', f); | |
| 296 | - nr--; | |
| 297 | - } | |
| 298 | - if (use_html && any) { | |
| 299 | - fprintf(f, "%s</font></pre></td></tr>\n" | |
| 300 | - " </table>\n" | |
| 301 | - " </body>\n" | |
| 302 | - "</html>\n", | |
| 303 | - current_high? "</b>": ""); | |
| 304 | - } | |
| 305 | - return True; | |
| 306 | -*/ | |
| 307 | -} | |
| 308 | - | |
| 309 | -/* Termination code for print text process. */ /* | |
| 310 | -static void | |
| 311 | -print_text_done(FILE *f, Boolean do_popdown | |
| 312 | -#if defined(X3270_DISPLAY) | |
| 313 | - unused | |
| 314 | -#endif | |
| 315 | - ) | |
| 316 | -{ | |
| 317 | - int status; | |
| 318 | - | |
| 319 | - status = pclose(f); | |
| 320 | - if (status) { | |
| 321 | - popup_an_error("Print program exited with status %d.", | |
| 322 | - (status & 0xff00) > 8); | |
| 323 | - } else { | |
| 324 | -#if defined(X3270_DISPLAY) | |
| 325 | - if (do_popdown) | |
| 326 | - XtPopdown(print_text_shell); | |
| 327 | - if (appres.do_confirms) | |
| 328 | - popup_an_info("Screen image printed."); | |
| 329 | -#endif | |
| 330 | - } | |
| 331 | - | |
| 332 | -} | |
| 333 | -*/ | |
| 334 | - | |
| 335 | -#if defined(X3270_DISPLAY) | |
| 336 | - | |
| 337 | -/* Callback for "OK" button on the print text popup. */ /* | |
| 338 | -static void | |
| 339 | -print_text_callback(Widget w unused, XtPointer client_data, | |
| 340 | - XtPointer call_data unused) | |
| 341 | -{ | |
| 342 | - char *filter; | |
| 343 | - FILE *f; | |
| 344 | - | |
| 345 | - filter = XawDialogGetValueString((Widget)client_data); | |
| 346 | - if (!filter) { | |
| 347 | - XtPopdown(print_text_shell); | |
| 348 | - return; | |
| 349 | - } | |
| 350 | - if (!(f = popen(filter, "w"))) { | |
| 351 | - popup_an_errno(errno, "popen(%s)", filter); | |
| 352 | - return; | |
| 353 | - } | |
| 354 | - (void) fprint_screen(f, True, False); | |
| 355 | - print_text_done(f, True); | |
| 356 | -} | |
| 357 | -*/ | |
| 358 | -/* Callback for "Plain Text" button on save text popup. *//* | |
| 359 | -static void | |
| 360 | -save_text_plain_callback(Widget w unused, XtPointer client_data, | |
| 361 | - XtPointer call_data unused) | |
| 362 | -{ | |
| 363 | - char *filename; | |
| 364 | - FILE *f; | |
| 365 | - | |
| 366 | - filename = XawDialogGetValueString((Widget)client_data); | |
| 367 | - if (!filename) { | |
| 368 | - XtPopdown(save_text_shell); | |
| 369 | - return; | |
| 370 | - } | |
| 371 | - if (!(f = fopen(filename, "a"))) { | |
| 372 | - popup_an_errno(errno, "%s", filename); | |
| 373 | - return; | |
| 374 | - } | |
| 375 | - (void) fprint_screen(f, True, False); | |
| 376 | - fclose(f); | |
| 377 | - XtPopdown(save_text_shell); | |
| 378 | - if (appres.do_confirms) | |
| 379 | - popup_an_info("Screen image saved."); | |
| 380 | -} | |
| 381 | -*/ | |
| 382 | -/* Callback for "HTML" button on save text popup. */ /* | |
| 383 | -static void | |
| 384 | -save_text_html_callback(Widget w unused, XtPointer client_data, | |
| 385 | - XtPointer call_data unused) | |
| 386 | -{ | |
| 387 | - char *filename; | |
| 388 | - FILE *f; | |
| 389 | - | |
| 390 | - filename = XawDialogGetValueString((Widget)client_data); | |
| 391 | - if (!filename) { | |
| 392 | - XtPopdown(save_text_shell); | |
| 393 | - return; | |
| 394 | - } | |
| 395 | - if (!(f = fopen(filename, "a"))) { | |
| 396 | - popup_an_errno(errno, "%s", filename); | |
| 397 | - return; | |
| 398 | - } | |
| 399 | - (void) fprint_screen(f, True, True); | |
| 400 | - fclose(f); | |
| 401 | - XtPopdown(save_text_shell); | |
| 402 | - if (appres.do_confirms) | |
| 403 | - popup_an_info("Screen image saved."); | |
| 404 | -} | |
| 405 | -*/ | |
| 406 | -/* Pop up the Print Text dialog, given a filter. */ /* | |
| 407 | -static void | |
| 408 | -popup_print_text(char *filter) | |
| 409 | -{ | |
| 410 | - if (print_text_shell == NULL) { | |
| 411 | - print_text_shell = create_form_popup("PrintText", | |
| 412 | - print_text_callback, (XtCallbackProc)NULL, | |
| 413 | - FORM_AS_IS); | |
| 414 | - XtVaSetValues(XtNameToWidget(print_text_shell, ObjDialog), | |
| 415 | - XtNvalue, filter, | |
| 416 | - NULL); | |
| 417 | - } | |
| 418 | - popup_popup(print_text_shell, XtGrabExclusive); | |
| 419 | -} | |
| 420 | -*/ | |
| 421 | -/* Pop up the Save Text dialog. */ /* | |
| 422 | -static void | |
| 423 | -popup_save_text(char *filename) | |
| 424 | -{ | |
| 425 | - if (save_text_shell == NULL) { | |
| 426 | - save_text_shell = create_form_popup("SaveText", | |
| 427 | - save_text_plain_callback, | |
| 428 | - save_text_html_callback, | |
| 429 | - FORM_AS_IS); | |
| 430 | - } | |
| 431 | - if (filename != CN) | |
| 432 | - XtVaSetValues(XtNameToWidget(save_text_shell, ObjDialog), | |
| 433 | - XtNvalue, filename, | |
| 434 | - NULL); | |
| 435 | - popup_popup(save_text_shell, XtGrabExclusive); | |
| 436 | -} | |
| 437 | -*/ | |
| 438 | - | |
| 439 | -#endif | |
| 440 | - | |
| 441 | -/* Print or save the contents of the screen as text. */ /* | |
| 442 | -void | |
| 443 | -PrintText_action(Widget w unused, XEvent *event, String *params, | |
| 444 | - Cardinal *num_params) | |
| 445 | -{ | |
| 446 | - int i; | |
| 447 | - char *filter = CN; | |
| 448 | - Boolean secure = appres.secure; | |
| 449 | - Boolean use_html = False; | |
| 450 | - Boolean use_file = False; | |
| 451 | - Boolean use_string = False; | |
| 452 | - | |
| 453 | - // | |
| 454 | - // Pick off optional arguments: | |
| 455 | - // file directs the output to a file instead of a command; | |
| 456 | - // must be the last keyword | |
| 457 | - // html generates HTML output instead of ASCII text (and implies | |
| 458 | - // 'file') | |
| 459 | - // secure disables the pop-up dialog, if this action is invoked from | |
| 460 | - // a keymap | |
| 461 | - // command directs the output to a command (this is the default, but | |
| 462 | - // allows the command to be one of the other keywords); | |
| 463 | - // must be the last keyword | |
| 464 | - // string returns the data as a string, allowed only from scripts | |
| 465 | - // | |
| 466 | - for (i = 0; i < *num_params; i++) { | |
| 467 | - if (!strcasecmp(params[i], "file")) { | |
| 468 | - use_file = True; | |
| 469 | - i++; | |
| 470 | - break; | |
| 471 | - } else if (!strcasecmp(params[i], "html")) { | |
| 472 | - use_html = True; | |
| 473 | - use_file = True; | |
| 474 | - } else if (!strcasecmp(params[i], "secure")) { | |
| 475 | - secure = True; | |
| 476 | - } else if (!strcasecmp(params[i], "command")) { | |
| 477 | - if (use_html || use_file) { | |
| 478 | - popup_an_error("%s: contradictory options", | |
| 479 | - action_name(PrintText_action)); | |
| 480 | - return; | |
| 481 | - } | |
| 482 | - i++; | |
| 483 | - break; | |
| 484 | - } else if (!strcasecmp(params[i], "string")) { | |
| 485 | - if (ia_cause != IA_SCRIPT) { | |
| 486 | - popup_an_error("%s(string) can only be used " | |
| 487 | - "from a script", | |
| 488 | - action_name(PrintText_action)); | |
| 489 | - return; | |
| 490 | - } | |
| 491 | - use_string = True; | |
| 492 | - use_file = True; | |
| 493 | - } else { | |
| 494 | - break; | |
| 495 | - } | |
| 496 | - } | |
| 497 | - switch (*num_params - i) { | |
| 498 | - case 0: | |
| 499 | - // Use the default. | |
| 500 | - if (!use_file) | |
| 501 | - filter = get_resource(ResPrintTextCommand); | |
| 502 | - break; | |
| 503 | - case 1: | |
| 504 | - if (use_string) { | |
| 505 | - popup_an_error("%s: extra arguments or invalid option(s)", | |
| 506 | - action_name(PrintText_action)); | |
| 507 | - return; | |
| 508 | - } | |
| 509 | - filter = params[i]; | |
| 510 | - break; | |
| 511 | - default: | |
| 512 | - popup_an_error("%s: extra arguments or invalid option(s)", | |
| 513 | - action_name(PrintText_action)); | |
| 514 | - return; | |
| 515 | - } | |
| 516 | - | |
| 517 | - if (filter != CN && filter[0] == '@') { | |
| 518 | - // | |
| 519 | - // Starting the PrintTextCommand resource value with '@' | |
| 520 | - // suppresses the pop-up dialog, as does setting the 'secure' | |
| 521 | - // resource. | |
| 522 | - // | |
| 523 | - secure = True; | |
| 524 | - filter++; | |
| 525 | - } | |
| 526 | - if (!use_file && (filter == CN || !*filter)) | |
| 527 | - filter = "lpr"; | |
| 528 | - | |
| 529 | -#if defined(X3270_DISPLAY) | |
| 530 | - if (secure || | |
| 531 | - ia_cause == IA_COMMAND || | |
| 532 | - ia_cause == IA_MACRO || | |
| 533 | - ia_cause == IA_SCRIPT) | |
| 534 | -#endif | |
| 535 | - { | |
| 536 | - FILE *f; | |
| 537 | - int fd = -1; | |
| 538 | - | |
| 539 | - // Invoked non-interactively. | |
| 540 | - if (use_file) { | |
| 541 | - if (use_string) { | |
| 542 | - char temp_name[15]; | |
| 543 | - | |
| 544 | -#if defined(_WIN32) | |
| 545 | - strcpy(temp_name, "x3hXXXXXX"); | |
| 546 | - mktemp(temp_name); | |
| 547 | - fd = _open(temp_name, _O_RDWR, | |
| 548 | - _S_IREAD | _S_IWRITE); | |
| 549 | -#else | |
| 550 | - strcpy(temp_name, "/tmp/x3hXXXXXX"); | |
| 551 | - fd = mkstemp(temp_name); | |
| 552 | -#endif | |
| 553 | - if (fd < 0) { | |
| 554 | - popup_an_errno(errno, "mkstemp"); | |
| 555 | - return; | |
| 556 | - } | |
| 557 | - (void) unlink(temp_name); | |
| 558 | - f = fdopen(fd, "w+"); | |
| 559 | - } else { | |
| 560 | - if (filter == CN || !*filter) { | |
| 561 | - popup_an_error("%s: missing filename", | |
| 562 | - action_name(PrintText_action)); | |
| 563 | - return; | |
| 564 | - } | |
| 565 | - f = fopen(filter, "a"); | |
| 566 | - } | |
| 567 | - } else | |
| 568 | - f = popen(filter, "w"); | |
| 569 | - if (f == NULL) { | |
| 570 | - popup_an_errno(errno, "%s: %s", | |
| 571 | - action_name(PrintText_action), | |
| 572 | - filter); | |
| 573 | - if (fd >= 0) { | |
| 574 | - (void) close(fd); | |
| 575 | - } | |
| 576 | - return; | |
| 577 | - } | |
| 578 | - (void) fprint_screen(f, True, use_html); | |
| 579 | - if (use_string) { | |
| 580 | - char buf[8192]; | |
| 581 | - | |
| 582 | - rewind(f); | |
| 583 | - while (fgets(buf, sizeof(buf), f) != NULL) | |
| 584 | - action_output(buf); | |
| 585 | - } | |
| 586 | - if (use_file) | |
| 587 | - fclose(f); | |
| 588 | - else | |
| 589 | - print_text_done(f, False); | |
| 590 | - return; | |
| 591 | - } | |
| 592 | - | |
| 593 | -#if defined(X3270_DISPLAY) | |
| 594 | - // Invoked interactively -- pop up the confirmation dialog. | |
| 595 | - if (use_file) { | |
| 596 | - popup_save_text(filter); | |
| 597 | - } else { | |
| 598 | - popup_print_text(filter); | |
| 599 | - } | |
| 600 | -#endif | |
| 601 | -} | |
| 602 | -*/ | |
| 603 | - | |
| 604 | -#if defined(X3270_DISPLAY) /*[*/ | |
| 605 | -#if defined(X3270_MENUS) /*[*/ | |
| 606 | - | |
| 607 | - | |
| 608 | -/* Callback for Print Text menu option. */ /* | |
| 609 | -void | |
| 610 | -print_text_option(Widget w, XtPointer client_data unused, | |
| 611 | - XtPointer call_data unused) | |
| 612 | -{ | |
| 613 | - char *filter = get_resource(ResPrintTextCommand); | |
| 614 | - Boolean secure = appres.secure; | |
| 615 | - Boolean use_html = False; | |
| 616 | - | |
| 617 | - // Decode the filter. | |
| 618 | - if (filter != CN && *filter == '@') { | |
| 619 | - secure = True; | |
| 620 | - filter++; | |
| 621 | - } | |
| 622 | - if (filter == CN || !*filter) | |
| 623 | - filter = "lpr"; | |
| 624 | - | |
| 625 | - if (secure) { | |
| 626 | - FILE *f; | |
| 627 | - | |
| 628 | - // Print the screen without confirming. | |
| 629 | - if (!(f = popen(filter, "w"))) { | |
| 630 | - popup_an_errno(errno, "popen(%s)", filter); | |
| 631 | - return; | |
| 632 | - } | |
| 633 | - (void) fprint_screen(f, True, use_html); | |
| 634 | - print_text_done(f, False); | |
| 635 | - } else { | |
| 636 | - // Pop up a dialog to confirm or modify their choice. | |
| 637 | - popup_print_text(filter); | |
| 638 | - } | |
| 639 | -} | |
| 640 | -*/ | |
| 641 | - | |
| 642 | -/* Callback for Save Text menu option. */ /* | |
| 643 | -void | |
| 644 | -save_text_option(Widget w, XtPointer client_data unused, | |
| 645 | - XtPointer call_data unused) | |
| 646 | -{ | |
| 647 | - // Pop up a dialog to confirm or modify their choice. | |
| 648 | - popup_save_text(CN); | |
| 649 | -} */ | |
| 650 | -#endif | |
| 651 | - | |
| 652 | - | |
| 653 | -/* Print Window popup */ | |
| 654 | - | |
| 655 | -/* | |
| 656 | - * Printing the window bitmap is a rather convoluted process: | |
| 657 | - * The PrintWindow action calls PrintWindow_action(), or a menu option calls | |
| 658 | - * print_window_option(). | |
| 659 | - * print_window_option() pops up the dialog. | |
| 660 | - * The OK button on the dialog triggers print_window_callback. | |
| 661 | - * print_window_callback pops down the dialog, then schedules a timeout | |
| 662 | - * 1 second away. | |
| 663 | - * When the timeout expires, it triggers snap_it(), which finally calls | |
| 664 | - * xwd. | |
| 665 | - * The timeout indirection is necessary because xwd prints the actual contents | |
| 666 | - * of the window, including any pop-up dialog in front of it. We pop down the | |
| 667 | - * dialog, but then it is up to the server and Xt to send us the appropriate | |
| 668 | - * expose events to repaint our window. Hopefully, one second is enough to do | |
| 669 | - * that. | |
| 670 | - */ | |
| 671 | - | |
| 672 | -/* Termination procedure for window print. */ /* | |
| 673 | -static void | |
| 674 | -print_window_done(int status) | |
| 675 | -{ | |
| 676 | - if (status) | |
| 677 | - popup_an_error("Print program exited with status %d.", | |
| 678 | - (status & 0xff00) >> 8); | |
| 679 | - else if (appres.do_confirms) | |
| 680 | - popup_an_info("Bitmap printed."); | |
| 681 | -} | |
| 682 | -*/ | |
| 683 | -/* Timeout callback for window print. */ /* | |
| 684 | -static void | |
| 685 | -snap_it(XtPointer closure unused, XtIntervalId *id unused) | |
| 686 | -{ | |
| 687 | - if (!print_window_command) | |
| 688 | - return; | |
| 689 | - XSync(display, 0); | |
| 690 | - print_window_done(system(print_window_command)); | |
| 691 | - print_window_command = CN; | |
| 692 | -} | |
| 693 | -*/ | |
| 694 | -/* Callback for "OK" button on print window popup. */ /* | |
| 695 | -static void | |
| 696 | -print_window_callback(Widget w unused, XtPointer client_data, | |
| 697 | - XtPointer call_data unused) | |
| 698 | -{ | |
| 699 | - print_window_command = XawDialogGetValueString((Widget)client_data); | |
| 700 | - XtPopdown(print_window_shell); | |
| 701 | - if (print_window_command) | |
| 702 | - (void) XtAppAddTimeOut(appcontext, 1000, snap_it, 0); | |
| 703 | -} */ | |
| 704 | - | |
| 705 | -/* Print the contents of the screen as a bitmap. */ /* | |
| 706 | -void | |
| 707 | -PrintWindow_action(Widget w unused, XEvent *event, String *params, | |
| 708 | - Cardinal *num_params) | |
| 709 | -{ | |
| 710 | - char *filter = get_resource(ResPrintWindowCommand); | |
| 711 | - char *fb = XtMalloc(strlen(filter) + 16); | |
| 712 | - char *xfb = fb; | |
| 713 | - Boolean secure = appres.secure; | |
| 714 | - | |
| 715 | - if (*num_params > 0) | |
| 716 | - filter = params[0]; | |
| 717 | - if (*num_params > 1) | |
| 718 | - popup_an_error("%s: extra arguments ignored", | |
| 719 | - action_name(PrintWindow_action)); | |
| 720 | - if (filter == CN) { | |
| 721 | - popup_an_error("%s: no %s defined", | |
| 722 | - action_name(PrintWindow_action), ResPrintWindowCommand); | |
| 723 | - return; | |
| 724 | - } | |
| 725 | - (void) sprintf(fb, filter, XtWindow(toplevel)); | |
| 726 | - if (fb[0] == '@') { | |
| 727 | - secure = True; | |
| 728 | - xfb = fb + 1; | |
| 729 | - } | |
| 730 | - if (secure) { | |
| 731 | - print_window_done(system(xfb)); | |
| 732 | - Free(fb); | |
| 733 | - return; | |
| 734 | - } | |
| 735 | - if (print_window_shell == NULL) | |
| 736 | - print_window_shell = create_form_popup("printWindow", | |
| 737 | - print_window_callback, (XtCallbackProc)NULL, FORM_AS_IS); | |
| 738 | - XtVaSetValues(XtNameToWidget(print_window_shell, ObjDialog), | |
| 739 | - XtNvalue, fb, | |
| 740 | - NULL); | |
| 741 | - popup_popup(print_window_shell, XtGrabExclusive); | |
| 742 | -} | |
| 743 | -*/ | |
| 744 | - | |
| 745 | -#if defined(X3270_MENUS) /*[*/ | |
| 746 | -/* Callback for menu Print Window option. */ /* | |
| 747 | -void | |
| 748 | -print_window_option(Widget w, XtPointer client_data unused, | |
| 749 | - XtPointer call_data unused) | |
| 750 | -{ | |
| 751 | - Cardinal zero = 0; | |
| 752 | - | |
| 753 | - PrintWindow_action(w, (XEvent *)NULL, (String *)NULL, &zero); | |
| 754 | -} */ | |
| 755 | -#endif /*]*/ | |
| 756 | - | |
| 757 | -#endif /*]*/ | ... | ... |
printerc.h
| ... | ... | @@ -17,11 +17,11 @@ |
| 17 | 17 | * Printer session support |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -LIB3270_INTERNAL void printer_init(void); | |
| 21 | -LIB3270_INTERNAL void printer_lu_dialog(void); | |
| 22 | -LIB3270_INTERNAL void printer_start(const char *lu); | |
| 23 | -LIB3270_INTERNAL void printer_stop(void); | |
| 24 | -LIB3270_INTERNAL Boolean printer_running(void); | |
| 20 | +// LIB3270_INTERNAL void printer_init(void); | |
| 21 | +// LIB3270_INTERNAL void printer_lu_dialog(void); | |
| 22 | +// LIB3270_INTERNAL void printer_start(const char *lu); | |
| 23 | +// LIB3270_INTERNAL void printer_stop(void); | |
| 24 | +// LIB3270_INTERNAL Boolean printer_running(void); | |
| 25 | 25 | #if defined(_WIN32) /*[*/ |
| 26 | -LIB3270_INTERNAL void printer_check(void); | |
| 26 | +// LIB3270_INTERNAL void printer_check(void); | |
| 27 | 27 | #endif /*]*/ | ... | ... |
resources.c
| ... | ... | @@ -33,7 +33,9 @@ |
| 33 | 33 | |
| 34 | 34 | #include <stdio.h> |
| 35 | 35 | #include <string.h> |
| 36 | + | |
| 36 | 37 | #include "globals.h" |
| 38 | +#include "utilc.h" | |
| 37 | 39 | |
| 38 | 40 | extern String fallbacks[]; |
| 39 | 41 | |
| ... | ... | @@ -103,11 +105,10 @@ static struct { |
| 103 | 105 | static struct dresource { |
| 104 | 106 | struct dresource *next; |
| 105 | 107 | const char *name; |
| 106 | - char *value; | |
| 108 | + const char *value; | |
| 107 | 109 | } *drdb = NULL, **drdb_next = &drdb; |
| 108 | 110 | |
| 109 | -void | |
| 110 | -add_resource(const char *name, char *value) | |
| 111 | +void add_resource(const char *name, const char *value) | |
| 111 | 112 | { |
| 112 | 113 | struct dresource *d; |
| 113 | 114 | |
| ... | ... | @@ -125,6 +126,7 @@ add_resource(const char *name, char *value) |
| 125 | 126 | drdb_next = &d->next; |
| 126 | 127 | } |
| 127 | 128 | |
| 129 | + | |
| 128 | 130 | const char * get_resource(const char *name) |
| 129 | 131 | { |
| 130 | 132 | struct dresource *d; |
| ... | ... | @@ -161,3 +163,19 @@ const char * get_resource(const char *name) |
| 161 | 163 | #endif |
| 162 | 164 | return NULL; |
| 163 | 165 | } |
| 166 | + | |
| 167 | +/* A version of get_resource that accepts sprintf arguments. */ | |
| 168 | +const char * get_fresource(const char *fmt, ...) | |
| 169 | +{ | |
| 170 | + va_list args; | |
| 171 | + char *name; | |
| 172 | + const char *r; | |
| 173 | + | |
| 174 | + va_start(args, fmt); | |
| 175 | + name = xs_vsprintf(fmt, args); | |
| 176 | + va_end(args); | |
| 177 | + r = get_resource(name); | |
| 178 | + Free(name); | |
| 179 | + return r; | |
| 180 | +} | |
| 181 | + | ... | ... |
util.c
| ... | ... | @@ -157,8 +157,7 @@ const char * win32_strerror(int e) |
| 157 | 157 | /* |
| 158 | 158 | * Cheesy internal version of sprintf that allocates its own memory. |
| 159 | 159 | */ |
| 160 | -static char * | |
| 161 | -xs_vsprintf(const char *fmt, va_list args) | |
| 160 | +char * xs_vsprintf(const char *fmt, va_list args) | |
| 162 | 161 | { |
| 163 | 162 | char *r; |
| 164 | 163 | #if defined(HAVE_VASPRINTF) /*[*/ |
| ... | ... | @@ -496,6 +495,7 @@ split_lresource(char **st, char **value) |
| 496 | 495 | #endif /*]*/ |
| 497 | 496 | |
| 498 | 497 | |
| 498 | +/* | |
| 499 | 499 | #if !defined(LIB3270) |
| 500 | 500 | |
| 501 | 501 | const char * |
| ... | ... | @@ -514,6 +514,7 @@ get_message(const char *key) |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | #endif |
| 517 | +*/ | |
| 517 | 518 | |
| 518 | 519 | #define ex_getenv getenv |
| 519 | 520 | |
| ... | ... | @@ -749,22 +750,6 @@ ctl_see(int c) |
| 749 | 750 | return buf; |
| 750 | 751 | } |
| 751 | 752 | |
| 752 | -/* A version of get_resource that accepts sprintf arguments. */ | |
| 753 | -char * | |
| 754 | -get_fresource(const char *fmt, ...) | |
| 755 | -{ | |
| 756 | - va_list args; | |
| 757 | - char *name; | |
| 758 | - char *r; | |
| 759 | - | |
| 760 | - va_start(args, fmt); | |
| 761 | - name = xs_vsprintf(fmt, args); | |
| 762 | - va_end(args); | |
| 763 | - r = get_resource(name); | |
| 764 | - Free(name); | |
| 765 | - return r; | |
| 766 | -} | |
| 767 | - | |
| 768 | 753 | /* |
| 769 | 754 | * Whitespace stripper. |
| 770 | 755 | */ | ... | ... |
utilc.h
| ... | ... | @@ -23,17 +23,20 @@ LIB3270_INTERNAL char *ctl_see(int c); |
| 23 | 23 | LIB3270_INTERNAL char *do_subst(const char *s, Boolean do_vars, Boolean do_tilde); |
| 24 | 24 | LIB3270_INTERNAL void fcatv(FILE *f, char *s); |
| 25 | 25 | LIB3270_INTERNAL const char *get_message(const char *key); |
| 26 | -LIB3270_INTERNAL char *get_fresource(const char *fmt, ...) printflike(1, 2); | |
| 27 | -LIB3270_INTERNAL char *get_resource(const char *name); | |
| 26 | +LIB3270_INTERNAL const char *get_fresource(const char *fmt, ...) printflike(1, 2); | |
| 27 | +LIB3270_INTERNAL const char *get_resource(const char *name); | |
| 28 | 28 | LIB3270_INTERNAL char *scatv(const char *s, char *buf, size_t len); |
| 29 | 29 | LIB3270_INTERNAL int split_dbcs_resource(const char *value, char sep, char **part1, |
| 30 | 30 | char **part2); |
| 31 | 31 | LIB3270_INTERNAL int split_dresource(char **st, char **left, char **right); |
| 32 | 32 | LIB3270_INTERNAL int split_lresource(char **st, char **value); |
| 33 | 33 | LIB3270_INTERNAL char *strip_whitespace(const char *s); |
| 34 | + | |
| 34 | 35 | LIB3270_INTERNAL char *xs_buffer(const char *fmt, ...) printflike(1, 2); |
| 35 | 36 | LIB3270_INTERNAL void xs_error(const char *fmt, ...) printflike(1, 2); |
| 36 | 37 | LIB3270_INTERNAL void xs_warning(const char *fmt, ...) printflike(1, 2); |
| 38 | +LIB3270_INTERNAL char * xs_vsprintf(const char *fmt, va_list args); | |
| 39 | + | |
| 37 | 40 | |
| 38 | 41 | LIB3270_INTERNAL unsigned long AddInput(int, H3270 *session, void (*fn)(H3270 *session)); |
| 39 | 42 | LIB3270_INTERNAL unsigned long AddExcept(int, H3270 *session, void (*fn)(H3270 *session)); | ... | ... |