version 1.1, 1998/07/27 03:26:10 |
version 1.2, 1998/11/03 21:59:53 |
|
|
|
/* $OpenBSD$ */ |
|
|
/**************************************************************************** |
/**************************************************************************** |
* Copyright (c) 1998 Free Software Foundation, Inc. * |
* Copyright (c) 1998 Free Software Foundation, Inc. * |
* * |
* * |
|
|
#include <termsort.c> /* this C file is generated */ |
#include <termsort.c> /* this C file is generated */ |
#include <parametrized.h> /* so is this */ |
#include <parametrized.h> /* so is this */ |
|
|
MODULE_ID("$Id$") |
MODULE_ID("$From: dump_entry.c,v 1.29 1998/09/26 13:15:00 tom Exp $") |
|
|
#define INDENT 8 |
#define INDENT 8 |
|
|
|
#define DISCARD(string) string = ABSENT_STRING |
|
|
static int tversion; /* terminfo version */ |
static int tversion; /* terminfo version */ |
static int outform; /* output format to use */ |
static int outform; /* output format to use */ |
static int sortmode; /* sort mode to use */ |
static int sortmode; /* sort mode to use */ |
|
|
int fmt_entry(TERMTYPE *tterm, |
int fmt_entry(TERMTYPE *tterm, |
int (*pred)(int type, int idx), |
int (*pred)(int type, int idx), |
bool suppress_untranslatable, |
bool suppress_untranslatable, |
bool infodump) |
bool infodump, |
|
bool numbers) |
{ |
{ |
int i, j; |
int i, j; |
char buffer[MAX_TERMINFO_LENGTH]; |
char buffer[MAX_TERMINFO_LENGTH]; |
|
|
* them to be output as defined and empty. |
* them to be output as defined and empty. |
*/ |
*/ |
if (outform==F_TERMCAP) |
if (outform==F_TERMCAP) |
|
{ |
#undef CUR |
#undef CUR |
#define CUR tterm-> |
#define CUR tterm-> |
if (insert_character || parm_ich) |
if (insert_character || parm_ich) |
|
|
} |
} |
} |
} |
|
|
|
if (init_3string != 0 |
|
&& termcap_reset != 0 |
|
&& !strcmp(init_3string, termcap_reset)) |
|
DISCARD(init_3string); |
|
|
|
if (reset_2string != 0 |
|
&& termcap_reset != 0 |
|
&& !strcmp(reset_2string, termcap_reset)) |
|
DISCARD(reset_2string); |
|
} |
|
|
predval = pred(STRING, i); |
predval = pred(STRING, i); |
buffer[0] = '\0'; |
buffer[0] = '\0'; |
if (predval != FAIL) { |
if (predval != FAIL) { |
|
|
sprintf(buffer, "%s@", str_names[i]); |
sprintf(buffer, "%s@", str_names[i]); |
else if (outform == F_TERMCAP || outform == F_TCONVERR) |
else if (outform == F_TERMCAP || outform == F_TCONVERR) |
{ |
{ |
char *srccap = _nc_tic_expand(tterm->Strings[i], FALSE); |
char *srccap = _nc_tic_expand(tterm->Strings[i], FALSE, numbers); |
char *cv = _nc_infotocap(str_names[i], srccap, parametrized[i]); |
char *cv = _nc_infotocap(str_names[i], srccap, parametrized[i]); |
|
|
if (cv == 0) |
if (cv == 0) |
|
|
} |
} |
else |
else |
{ |
{ |
char *src = _nc_tic_expand(tterm->Strings[i], outform==F_TERMINFO); |
char *src = _nc_tic_expand(tterm->Strings[i], outform==F_TERMINFO, numbers); |
sprintf(buffer, "%s=", str_names[i]); |
sprintf(buffer, "%s=", str_names[i]); |
if (pretty && outform==F_TERMINFO) |
if (pretty && outform==F_TERMINFO) |
fmt_complex(buffer + strlen(buffer), src, 1); |
fmt_complex(buffer + strlen(buffer), src, 1); |
|
|
if (box_ok) |
if (box_ok) |
{ |
{ |
(void) strcpy(buffer, "box1="); |
(void) strcpy(buffer, "box1="); |
(void) strcat(buffer, _nc_tic_expand(boxchars, outform==F_TERMINFO)); |
(void) strcat(buffer, _nc_tic_expand(boxchars, outform==F_TERMINFO, numbers)); |
WRAP_CONCAT; |
WRAP_CONCAT; |
} |
} |
} |
} |
|
|
return(infodump ? len : termcap_length(outbuf)); |
return(infodump ? len : termcap_length(outbuf)); |
} |
} |
|
|
int dump_entry(TERMTYPE *tterm, bool limited, int (*pred)(int type, int idx)) |
int dump_entry(TERMTYPE *tterm, bool limited, bool numbers, int (*pred)(int type, int idx)) |
/* dump a single entry */ |
/* dump a single entry */ |
{ |
{ |
int len, critlen; |
int len, critlen; |
|
|
infodump = TRUE; |
infodump = TRUE; |
} |
} |
|
|
if (((len = fmt_entry(tterm, pred, FALSE, infodump)) > critlen) && limited) |
if (((len = fmt_entry(tterm, pred, FALSE, infodump, numbers)) > critlen) && limited) |
{ |
{ |
(void) printf("# (untranslatable capabilities removed to fit entry within %d bytes)\n", |
(void) printf("# (untranslatable capabilities removed to fit entry within %d bytes)\n", |
critlen); |
critlen); |
if ((len = fmt_entry(tterm, pred, TRUE, infodump)) > critlen) |
if ((len = fmt_entry(tterm, pred, TRUE, infodump, numbers)) > critlen) |
{ |
{ |
/* |
/* |
* We pick on sgr because it's a nice long string capability that |
* We pick on sgr because it's a nice long string capability that |
|
|
set_attributes = ABSENT_STRING; |
set_attributes = ABSENT_STRING; |
(void) printf("# (sgr removed to fit entry within %d bytes)\n", |
(void) printf("# (sgr removed to fit entry within %d bytes)\n", |
critlen); |
critlen); |
if ((len = fmt_entry(tterm, pred, TRUE, infodump)) > critlen) |
if ((len = fmt_entry(tterm, pred, TRUE, infodump, numbers)) > critlen) |
{ |
{ |
int oldversion = tversion; |
int oldversion = tversion; |
|
|
|
|
(void) printf("# (terminfo-only capabilities suppressed to fit entry within %d bytes)\n", |
(void) printf("# (terminfo-only capabilities suppressed to fit entry within %d bytes)\n", |
critlen); |
critlen); |
|
|
if ((len = fmt_entry(tterm, pred, TRUE, infodump)) > critlen) |
if ((len = fmt_entry(tterm, pred, TRUE, infodump, numbers)) > critlen) |
{ |
{ |
(void) fprintf(stderr, |
(void) fprintf(stderr, |
"warning: %s entry is %d bytes long\n", |
"warning: %s entry is %d bytes long\n", |