From: Ralph Corderoy Date: Mon, 28 Aug 2017 18:33:53 +0000 (+0100) Subject: Move terminal.c's prototypes from prototypes.h to new terminal.h. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/ecd50cc5f6c2a427e821483993678b78c94ffdfd?ds=sidebyside Move terminal.c's prototypes from prototypes.h to new terminal.h. --- diff --git a/Makefile.am b/Makefile.am index 9781dfd0..3a3f9a42 100644 --- a/Makefile.am +++ b/Makefile.am @@ -367,6 +367,7 @@ noinst_HEADERS = \ sbr/makedir.h \ sbr/message_id.h \ sbr/mime_type.h \ + sbr/terminal.h \ sbr/unquote.h \ thirdparty/jsmn/jsmn.h \ uip/mhfree.h \ diff --git a/h/prototypes.h b/h/prototypes.h index e62ea065..ab9e83d7 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -171,57 +171,6 @@ char *getcpy(const char *str); char *get_default_editor(void); char *getfolder(int) PURE; -/* - * Get a string from the terminfo database for the current terminal. - * - * Retrieve the specified terminfo capability and return a string that - * can be output to the terminal. The string returned has already been - * processed by tputs(), so it is safe to output directly. The return - * value of this function is valid until the next call. - * - * Arguments: - * - * capability - The name of the terminfo capability (see terminfo(5)). - * - * Returns a tputs-processed string, or NULL if terminal initialization failed - * or the capability wasn't found. - */ -char *get_term_stringcap(char *capability); - -/* - * Get a parameterized string from the terminfo database for the current - * terminal. - * - * We don't yet have a standardized tparm() that will take a stdarg - * argument. Right now we don't want many parameters, so we only - * take two. Everything gets passed to tparm() as-is. If we need - * a capability with more arguments, we'll just add more later. - * - * Arguments: - * - * capability - The name of the terminfo capability (see terminfo(5)). - * arg1..argN - Arguments 1-N. - * - * Returns a tparm and tputs-processed string, or NULL if there was a problem - * initialising the terminal or retrieving the capability. - */ -char *get_term_stringparm(char *capability, long arg1, long arg2); - -/* - * Get a number from the terminfo database for the current terminal. - * - * Retrieve the specified terminfo capability and return the numeric - * value of that capability from the terminfo database. - * - * Arguments: - * - * capability - The name of the terminfo capability (see terminfo(5)). - * - * Returns the output of tigetnum() for that capability, or -1 if it was - * unable to initialize the terminfo database. - */ -int get_term_numcap(char *capability); - int m_atoi (char *) PURE; char *m_backup (const char *); int m_convert (struct msgs *, char *); @@ -240,10 +189,6 @@ char *m_name (int); void m_unknown(m_getfld_state_t *, FILE *); void m_unknown2(m_getfld_state_t *); -/* - * Clear the screen, using the appropriate entry from the terminfo database - */ -void nmh_clear_screen(void); char *nmh_getpass(const char *); char *new_fs (char *, char *, char *); char *path(char *, int); @@ -380,12 +325,9 @@ int mhlsbr(int, char **, FILE *(*)(char *)); int distout (char *, char *, char *); void replout (FILE *, char *, char *, struct msgs *, int, int, char *, char *, char *, int); -int sc_length(void); -int sc_width(void); int build_form (char *, char *, int *, char *, char *, char *, char *, char *, char *); int sendsbr (char **, int, char *, char *, struct stat *, int, const char *); -int SOprintf (char *, ...) CHECK_PRINTF(1, 2); int what_now (char *, int, int, char *, char *, int, struct msgs *, char *, int, char *, int); int WhatNow(int, char **) NORETURN; diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index a9dad42b..3930f8ca 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -46,6 +46,7 @@ #include #include #include +#include "terminal.h" #ifdef HAVE_SYS_TIME_H # include diff --git a/sbr/terminal.c b/sbr/terminal.c index 51dd1298..761ed245 100644 --- a/sbr/terminal.c +++ b/sbr/terminal.c @@ -19,6 +19,8 @@ # include #endif +#include "terminal.h" + static int initLI = 0; static int initCO = 0; @@ -148,8 +150,19 @@ SOprintf (char *fmt, ...) } /* - * Return the specified capability as a string that has already been - * processed with tputs(). + * Get a string from the terminfo database for the current terminal. + * + * Retrieve the specified terminfo capability and return a string that + * can be output to the terminal. The string returned has already been + * processed by tputs(), so it is safe to output directly. The return + * value of this function is valid until the next call. + * + * Arguments: + * + * capability - The name of the terminfo capability (see terminfo(5)). + * + * Returns a tputs-processed string, or NULL if terminal initialization failed + * or the capability wasn't found. */ char * @@ -178,9 +191,22 @@ get_term_stringcap(char *capability) } /* - * Return a parameterized terminfo capability + * Get a parameterized string from the terminfo database for the current + * terminal. + * + * We don't yet have a standardized tparm() that will take a stdarg + * argument. Right now we don't want many parameters, so we only + * take two. Everything gets passed to tparm() as-is. If we need + * a capability with more arguments, we'll just add more later. + * + * Arguments: + * + * capability - The name of the terminfo capability (see terminfo(5)). + * arg1..argN - Arguments 1-N. + * + * Returns a tparm and tputs-processed string, or NULL if there was a problem + * initialising the terminal or retrieving the capability. */ - char * get_term_stringparm(char *capability, long arg1, long arg2) { @@ -209,9 +235,18 @@ get_term_stringparm(char *capability, long arg1, long arg2) } /* - * Return the value of the specified numeric capability + * Get a number from the terminfo database for the current terminal. + * + * Retrieve the specified terminfo capability and return the numeric + * value of that capability from the terminfo database. + * + * Arguments: + * + * capability - The name of the terminfo capability (see terminfo(5)). + * + * Returns the output of tigetnum() for that capability, or -1 if it was + * unable to initialize the terminfo database. */ - int get_term_numcap(char *capability) { diff --git a/sbr/terminal.h b/sbr/terminal.h new file mode 100644 index 00000000..867a9fdf --- /dev/null +++ b/sbr/terminal.h @@ -0,0 +1,14 @@ +/* terminal.h -- termcap support + * + * This code is Copyright (c) 2017, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. + */ + +int sc_width(void); +int sc_length(void); +void nmh_clear_screen(void); +int SOprintf(char *fmt, ...) CHECK_PRINTF(1, 2); +char *get_term_stringcap(char *capability); +char *get_term_stringparm(char *capability, long arg1, long arg2); +int get_term_numcap(char *capability); diff --git a/uip/ap.c b/uip/ap.c index a44ecf55..a20747f9 100644 --- a/uip/ap.c +++ b/uip/ap.c @@ -10,6 +10,7 @@ #include #include #include +#include "../sbr/terminal.h" #define NADDRS 100 diff --git a/uip/dp.c b/uip/dp.c index ece04a3f..617da203 100644 --- a/uip/dp.c +++ b/uip/dp.c @@ -9,6 +9,7 @@ #include #include #include +#include "../sbr/terminal.h" #define NDATES 100 diff --git a/uip/fmttest.c b/uip/fmttest.c index d5d47318..1c4159a8 100644 --- a/uip/fmttest.c +++ b/uip/fmttest.c @@ -12,6 +12,7 @@ #include #include #include "../sbr/m_maildir.h" +#include "../sbr/terminal.h" #define FMTTEST_SWITCHES \ X("form formatfile", 0, FORMSW) \ diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index 7625312e..d32d38f9 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -14,6 +14,7 @@ #include "../sbr/m_popen.h" #include #include +#include "../sbr/terminal.h" /* * MAJOR BUG: diff --git a/uip/scan.c b/uip/scan.c index d9d8ca9d..b65fef74 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -12,6 +12,7 @@ #include #include #include "../sbr/m_maildir.h" +#include "../sbr/terminal.h" #define SCAN_SWITCHES \ X("clear", 0, CLRSW) \ diff --git a/uip/scansbr.c b/uip/scansbr.c index 24609d26..bbc5a168 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -11,6 +11,7 @@ #include #include #include +#include "../sbr/terminal.h" static struct format *fmt; static struct comp *datecomp; /* pntr to "date" comp */