K&R textio: conversion to ANSI

K&R obsolete syntax removal for C23 compatibility series
This commit is contained in:
Darryl L. Miles 2025-01-31 17:11:07 +00:00 committed by Tim Edwards
parent 6c6e48a9a3
commit 8cce1bdb7e
3 changed files with 52 additions and 49 deletions

View File

@ -26,6 +26,7 @@
#define _TEXTIO_H #define _TEXTIO_H
#include "utils/magic.h" #include "utils/magic.h"
#include "utils/dqueue.h" /* DQueue */
#ifdef MAGIC_WRAPPER #ifdef MAGIC_WRAPPER
extern char *TxBuffer; extern char *TxBuffer;
@ -58,13 +59,13 @@ extern int TxCurButtons;
#endif /* MAGIC_WRAPPER */ #endif /* MAGIC_WRAPPER */
/* printing procedures */ /* printing procedures */
extern bool TxPrintOn(); /* enables TxPrintf output */ extern bool TxPrintOn(void); /* enables TxPrintf output */
extern bool TxPrintOff(); /* disables TxPrintf output */ extern bool TxPrintOff(void); /* disables TxPrintf output */
extern void TxFlush(); extern void TxFlush(void);
extern void TxFlushOut(); extern void TxFlushOut(void);
extern void TxFlushErr(); extern void TxFlushErr(void);
extern void TxUseMore(); extern void TxUseMore(void);
extern void TxStopMore(); extern void TxStopMore(void);
/* printing procedures with variable arguments lists */ /* printing procedures with variable arguments lists */
extern void TxError(const char *, ...) ATTR_FORMAT_PRINTF_1; extern void TxError(const char *, ...) ATTR_FORMAT_PRINTF_1;
@ -73,30 +74,30 @@ extern void TxPrintf(const char *, ...) ATTR_FORMAT_PRINTF_1;
extern char *TxPrintString(const char *, ...) ATTR_FORMAT_PRINTF_1; extern char *TxPrintString(const char *, ...) ATTR_FORMAT_PRINTF_1;
/* input procedures */ /* input procedures */
extern char *TxGetLinePrompt(); extern char *TxGetLinePrompt(char *dest, int maxChars, char *prompt);
extern char *TxGetLine(); extern char *TxGetLine(char *line, int len);
extern int TxGetChar(); extern int TxGetChar(void);
extern int TxDialog(); extern int TxDialog(char *prompt, char *(responses[]), int defresp);
/* prompting procedures */ /* prompting procedures */
extern void TxSetPrompt(); extern void TxSetPrompt(char ch);
extern void TxPrompt(); extern void TxPrompt(void);
extern void TxUnPrompt(); extern void TxUnPrompt(void);
extern void TxRestorePrompt(); extern void TxRestorePrompt(void);
extern void TxReprint(); extern void TxReprint(void);
/* terminal-state procedures */ /* terminal-state procedures */
extern void TxSetTerminal(); extern void TxSetTerminal(void);
extern void TxResetTerminal(bool force); extern void TxResetTerminal(bool force);
extern char TxEOFChar; /* The current EOF character */ extern char TxEOFChar; /* The current EOF character */
extern char TxInterruptChar; /* The current interrupt character */ extern char TxInterruptChar; /* The current interrupt character */
/* command procedures */ /* command procedures */
extern void TxDispatch(); extern void TxDispatch(FILE *f);
/* C99 compat */ /* C99 compat */
extern void TxMore(); extern void TxMore(char *mesg);
extern void txGetFileCommand(); extern void txGetFileCommand(FILE *f, DQueue *queue);
/* variables that tell if stdin and stdout are to a terminal */ /* variables that tell if stdin and stdout are to a terminal */
extern bool TxStdinIsatty; extern bool TxStdinIsatty;
@ -104,9 +105,9 @@ extern bool TxStdoutIsatty;
#define TxInteractive (TxStdinIsatty && TxStdoutIsatty) #define TxInteractive (TxStdinIsatty && TxStdoutIsatty)
/* Misc procs */ /* Misc procs */
void TxInit(); extern void TxInit(void);
#ifdef USE_READLINE #ifdef USE_READLINE
void TxInitReadline(); extern void TxInitReadline(void);
#endif #endif
#define TX_MAX_OPEN_FILES 20 #define TX_MAX_OPEN_FILES 20

View File

@ -22,6 +22,7 @@
#ifndef _TEXTIOINT_H #ifndef _TEXTIOINT_H
#define _TEXTIOINT_H #define _TEXTIOINT_H
#include "utils/magic.h"
#include "textio/textio.h" #include "textio/textio.h"
#include "textio/txcommands.h" #include "textio/txcommands.h"
@ -48,16 +49,16 @@ typedef struct {
} txTermState; } txTermState;
#endif /* SYSV */ #endif /* SYSV */
extern bool TxGetInputEvent(); extern bool TxGetInputEvent(bool block, bool returnOnSigWinch);
/* Routines with variable argument lists */ /* Routines with variable argument lists */
extern void txFprintfBasic(FILE *, const char *fmt, ...) ATTR_FORMAT_PRINTF_2; extern void txFprintfBasic(FILE *f, const char *fmt, ...) ATTR_FORMAT_PRINTF_2;
/* C99 compat */ /* C99 compat */
void txCommandsInit(); extern void txCommandsInit(void);
int TranslateChar(); extern int TranslateChar(int key);
char *TxGetLineWPrompt(); extern char *TxGetLineWPrompt(char *dest, int maxChars, char *prompt, char *prefix);
#ifdef MAGIC_WRAPPER #ifdef MAGIC_WRAPPER
/* tcltk/tclmagic.c has a function implementation prototype mimics vfprintf() mapping /* tcltk/tclmagic.c has a function implementation prototype mimics vfprintf() mapping

View File

@ -23,6 +23,7 @@
#include "utils/magic.h" #include "utils/magic.h"
#include "utils/geometry.h" #include "utils/geometry.h"
#include "windows/windows.h" /* MagWindow */
/* Structure of one Magic command. All commands are in the same format. /* Structure of one Magic command. All commands are in the same format.
* Commands are tagged with the point and window at which the command was * Commands are tagged with the point and window at which the command was
@ -117,24 +118,24 @@ extern TxCommand TxCurCommand;
/* procedures to help in making device command routines */ /* procedures to help in making device command routines */
extern void TxAddInputDevice(const fd_set *fdmask, void (*inputProc)(), ClientData cdata); /* Can read multiple file desc. */ extern void TxAddInputDevice(const fd_set *fdmask, void (*inputProc)(), ClientData cdata); /* Can read multiple file desc. */
extern void TxAdd1InputDevice(); /* Can read only 1 file desc. */ extern void TxAdd1InputDevice(int fd, void (*inputProc)(), ClientData cdata); /* Can read only 1 file desc. */
extern void TxDeleteInputDevice(const fd_set *fdmask); extern void TxDeleteInputDevice(const fd_set *fdmask);
extern void TxDelete1InputDevice(); extern void TxDelete1InputDevice(int fd);
/* Routines to manipulate the current point. Only really used for command /* Routines to manipulate the current point. Only really used for command
* scripts. * scripts.
*/ */
extern void TxSetPoint(); extern void TxSetPoint(int x, int y, int wid);
extern int TxGetPoint(); extern int TxGetPoint(Point *tx_p);
extern void TxClearPoint(); extern void TxClearPoint(void);
/* Routines to handle command logging. /* Routines to handle command logging.
*/ */
extern void TxLogStart(); extern void TxLogStart(char *fileName, MagWindow *mw);
extern void TxLogStop(); extern void TxLogStop(void);
extern void TxLogUpdate(); extern void TxLogUpdate(void);
extern void TxLogSuspend(); extern void TxLogSuspend(void);
extern void TxLogResume(); extern void TxLogResume(void);
/* Routines for handling input events. A typical device driver in the /* Routines for handling input events. A typical device driver in the
@ -142,25 +143,25 @@ extern void TxLogResume();
* then put them in the input queue via TxAddEvent(). * then put them in the input queue via TxAddEvent().
*/ */
extern TxInputEvent *TxNewEvent(); extern TxInputEvent *TxNewEvent(void);
extern void TxAddEvent(); extern void TxAddEvent(TxInputEvent *event);
extern void TxPrintEvent(); extern void TxPrintEvent(TxInputEvent *event);
extern void TxFreeEvent(); extern void TxFreeEvent(TxInputEvent *event);
extern void TxReleaseButton(); extern void TxReleaseButton(int but);
/* Routines for dealing with commands. Usually only used within this /* Routines for dealing with commands. Usually only used within this
* module, although they may be used elsewhere. * module, although they may be used elsewhere.
*/ */
extern void TxPrintCommand(); extern void TxPrintCommand(TxCommand *cmd);
extern TxCommand *TxNewCommand(); extern TxCommand *TxNewCommand(void);
extern void TxFreeCommand(); extern void TxFreeCommand(TxCommand *command);
extern void TxParseString(); extern void TxParseString(char *str, void *q, void *event);
extern void TxDispatch(); extern void TxDispatch(FILE *f);
extern void TxRebuildCommand(); extern void TxRebuildCommand(TxCommand *cmd);
extern int TxCommandNumber; /* Serial number of current command. */ extern int TxCommandNumber; /* Serial number of current command. */
#ifdef MAGIC_WRAPPER #ifdef MAGIC_WRAPPER
extern int TxTclDispatch(); extern int TxTclDispatch(ClientData clientData, int argc, char *argv[], bool quiet);
#endif #endif
#endif /* _TXCOMMANDS_H */ #endif /* _TXCOMMANDS_H */