1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00

Move all extern declarations into header files.

This is another cleanup I felt a need for while I was doing
boolification. If you define a function or variable in one .c file and
declare it extern in another, then nothing will check you haven't got
the types of the two declarations mismatched - so when you're
_changing_ the type, it's a pain to make sure you've caught all the
copies of it.

It's better to put all those extern declarations in header files, so
that the declaration in the header is also in scope for the
definition. Then the compiler will complain if they don't match, which
is what I want.
This commit is contained in:
Simon Tatham 2018-11-03 10:06:33 +00:00
parent 91d16881ab
commit c5895ec292
31 changed files with 136 additions and 119 deletions

1
misc.c
View File

@ -1258,7 +1258,6 @@ bool strendswith(const char *s, const char *t)
char *buildinfo(const char *newline)
{
strbuf *buf = strbuf_new();
extern const char commitid[]; /* in commitid.c */
strbuf_catf(buf, "Build platform: %d-bit %s",
(int)(CHAR_BIT * sizeof(void *)),

View File

@ -1709,6 +1709,7 @@ void ser_setup_config_box(struct controlbox *b, bool midsession,
* Exports from version.c.
*/
extern const char ver[];
extern const char commitid[];
/*
* Exports from unicode.c.
@ -1853,6 +1854,9 @@ void conf_filesel_handler(union control *ctrl, dlgparam *dlg,
void *data, int event);
void conf_fontsel_handler(union control *ctrl, dlgparam *dlg,
void *data, int event);
/* Much more special-purpose function needed by sercfg.c */
void config_protocolbuttons_handler(union control *, dlgparam *, void *, int);
void setup_config_box(struct controlbox *b, bool midsession,
int protocol, int protcfginfo);

View File

@ -132,8 +132,6 @@ void ser_setup_config_box(struct controlbox *b, bool midsession,
if (!midsession) {
int i;
extern void config_protocolbuttons_handler(union control *, dlgparam *,
void *, int);
/*
* Add the serial back end to the protocols list at the

8
ssh.h
View File

@ -185,6 +185,12 @@ void share_setup_x11_channel(ssh_sharing_connstate *cs, share_channel *chan,
int protomajor, int protominor,
const void *initial_data, int initial_len);
/* Per-application overrides for what roles we can take in connection
* sharing, regardless of user configuration (e.g. pscp will never be
* an upstream) */
extern const bool share_can_be_downstream;
extern const bool share_can_be_upstream;
struct X11Display;
struct X11FakeAuth;
@ -418,6 +424,8 @@ struct ec_point {
bool infinity;
};
/* A couple of ECC functions exported for use outside sshecc.c */
struct ec_point *ecp_mul(const struct ec_point *a, const Bignum b);
void ec_point_free(struct ec_point *point);
/* Weierstrass form curve */

View File

@ -325,13 +325,6 @@ static bool ssh2_connection_filter_queue(struct ssh2_connection_state *s)
ChanopenResult chanopen_result;
PacketProtocolLayer *ppl = &s->ppl; /* for ppl_logevent */
/* Cross-reference to ssh2transport.c to handle the common packets
* between login and connection: DISCONNECT, DEBUG and IGNORE. If
* we have an instance of ssh2transport below us, then those
* messages won't come here anyway, but they could if we're
* running in bare ssh2-connection mode. */
extern bool ssh2_common_filter_queue(PacketProtocolLayer *ppl);
while (1) {
if (ssh2_common_filter_queue(&s->ppl))
return true;

View File

@ -4,9 +4,6 @@
#include "ssh.h"
/* Forward reference from sshecc.c */
struct ec_point *ecp_mul(const struct ec_point *a, const Bignum b);
int ec_generate(struct ec_key *key, int bits, progfn_t pfn,
void *pfnparam)
{

View File

@ -134,6 +134,13 @@ void ssh_ppl_user_output_string_and_free(PacketProtocolLayer *ppl, char *text);
ptrlen ssh2_transport_get_session_id(PacketProtocolLayer *ssh2_transport_ptr);
void ssh2_transport_notify_auth_done(PacketProtocolLayer *ssh2_transport_ptr);
/* Shared method between ssh2 layers (defined in ssh2transport.c) to
* handle the common packets between login and connection: DISCONNECT,
* DEBUG and IGNORE. Those messages are handled by the ssh2transport
* layer if we have one, but in bare ssh2-connection mode they have to
* be handled by ssh2connection. */
bool ssh2_common_filter_queue(PacketProtocolLayer *ppl);
/* Methods for ssh1login to pass protocol flags to ssh1connection */
void ssh1_connection_set_protoflags(
PacketProtocolLayer *ppl, int local, int remote);

View File

@ -9,9 +9,6 @@
/* Collect environmental noise every 5 minutes */
#define NOISE_REGULAR_INTERVAL (5*60*TICKSPERSEC)
void noise_get_heavy(void (*func) (void *, int));
void noise_get_light(void (*func) (void *, int));
/*
* `pool' itself is a pool of random data which we actually use: we
* return bytes from `pool', at position `poolpos', until `poolpos'

View File

@ -1968,11 +1968,6 @@ static int share_listen_accepting(Plug *plug,
return 0;
}
/* Per-application overrides for what roles we can take (e.g. pscp
* will never be an upstream) */
extern const bool share_can_be_downstream;
extern const bool share_can_be_upstream;
/*
* Decide on the string used to identify the connection point between
* upstream and downstream (be it a Windows named pipe or a

View File

@ -1051,7 +1051,6 @@ static void null_line_error(Terminal *term, int y, int lineno,
tree234 *whichtree, int treeindex,
const char *varname)
{
extern const char commitid[]; /* in version.c */
modalfatalbox("%s==NULL in terminal.c\n"
"lineno=%d y=%d w=%d h=%d\n"
"count(scrollback=%p)=%d\n"

View File

@ -107,8 +107,6 @@ void session_window_closed(void) {}
void window_setup_error(const char *errmsg) {}
#else /* GTK_CHECK_VERSION(3,0,0) */
extern const bool use_event_log;
static void startup(GApplication *app, gpointer user_data)
{
GMenu *menubar, *menu, *section;
@ -216,7 +214,6 @@ GtkWidget *make_gtk_toplevel_window(GtkFrontend *frontend)
void launch_duplicate_session(Conf *conf)
{
extern const bool dup_check_launchable;
assert(!dup_check_launchable || conf_launchable(conf));
g_application_hold(G_APPLICATION(app));
new_session_window(conf_copy(conf), NULL);
@ -315,15 +312,11 @@ int main(int argc, char **argv)
{
int status;
{
/* Call the function in ux{putty,pterm}.c to do app-type
* specific setup */
extern void setup(bool);
setup(false); /* false means we are not a one-session process */
}
/* Call the function in ux{putty,pterm}.c to do app-type
* specific setup */
setup(false); /* false means we are not a one-session process */
if (argc > 1) {
extern char *pty_osx_envrestore_prefix;
pty_osx_envrestore_prefix = argv[--argc];
}

View File

@ -3189,15 +3189,7 @@ GtkWidget *create_config_box(const char *title, Conf *conf,
dp->retval = -1;
dp->window = window;
{
/* in gtkwin.c */
extern void set_window_icon(GtkWidget *window,
const char *const *const *icon,
int n_icon);
extern const char *const *const cfg_icon[];
extern const int n_cfg_icon;
set_window_icon(window, cfg_icon, n_cfg_icon);
}
set_window_icon(window, cfg_icon, n_cfg_icon);
#if !GTK_CHECK_VERSION(2,0,0)
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(treescroll),
@ -3860,8 +3852,6 @@ static void eventlog_list_handler(union control *ctrl, dlgparam *dp,
if (gtk_selection_owner_set(es->window, GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME)) {
extern GdkAtom compound_text_atom;
gtk_selection_add_target(es->window, GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING, 1);
gtk_selection_add_target(es->window, GDK_SELECTION_PRIMARY,

View File

@ -47,9 +47,6 @@
static char *progname, **gtkargvstart;
static int ngtkargs;
extern char **pty_argv; /* declared in pty.c */
extern bool use_pty_argv;
static const char *app_name = "pterm";
char *x_get_default(const char *key)
@ -590,12 +587,9 @@ int main(int argc, char **argv)
setlocale(LC_CTYPE, "");
{
/* Call the function in ux{putty,pterm}.c to do app-type
* specific setup */
extern void setup(bool);
setup(true); /* true means we are a one-session process */
}
/* Call the function in ux{putty,pterm}.c to do app-type
* specific setup */
setup(true); /* true means we are a one-session process */
progname = argv[0];
@ -626,8 +620,6 @@ int main(int argc, char **argv)
block_signal(SIGPIPE, true);
if (argc > 1 && !strncmp(argv[1], "---", 3)) {
extern const bool dup_check_launchable;
read_dupsession_data(conf, argv[1]);
/* Splatter this argument so it doesn't clutter a ps listing */
smemclr(argv[1], strlen(argv[1]));

View File

@ -5468,11 +5468,7 @@ void new_session_window(Conf *conf, const char *geometry_string)
#endif
);
{
extern const char *const *const main_icon[];
extern const int n_main_icon;
set_window_icon(inst->window, main_icon, n_main_icon);
}
set_window_icon(inst->window, main_icon, n_main_icon);
gtk_widget_show(inst->window);
@ -5484,7 +5480,6 @@ void new_session_window(Conf *conf, const char *geometry_string)
{
GtkWidget *menuitem;
char *s;
extern const bool use_event_log, new_session, saved_sessions;
inst->menu = gtk_menu_new();

View File

@ -189,7 +189,14 @@ enum MenuAction {
};
void app_menu_action(GtkFrontend *frontend, enum MenuAction);
/* Things gtkdlg.c needs from pterm.c */
/* Arrays of pixmap data used for GTK window icons. (main_icon is for
* the process's main window; cfg_icon is the modified icon used for
* its config box.) */
extern const char *const *const main_icon[];
extern const char *const *const cfg_icon[];
extern const int n_main_icon, n_cfg_icon;
/* Things gtkdlg.c needs from gtkwin.c */
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
enum DialogSlot {
DIALOG_SLOT_RECONFIGURE,
@ -202,9 +209,12 @@ enum DialogSlot {
GtkWidget *gtk_seat_get_window(Seat *seat);
void register_dialog(Seat *seat, enum DialogSlot slot, GtkWidget *dialog);
void unregister_dialog(Seat *seat, enum DialogSlot slot);
void set_window_icon(GtkWidget *window, const char *const *const *icon,
int n_icon);
extern GdkAtom compound_text_atom;
#endif
/* Things pterm.c needs from gtkdlg.c */
/* Things gtkwin.c needs from gtkdlg.c */
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
GtkWidget *create_config_box(const char *title, Conf *conf,
bool midsession, int protcfginfo,
@ -247,18 +257,52 @@ GtkWidget *create_message_box(
post_dialog_fn_t after, void *afterctx);
#endif
/* Things pterm.c needs from {ptermm,uxputty}.c */
/* Things gtkwin.c needs from {ptermm,uxputty}.c */
char *make_default_wintitle(char *hostname);
/* pterm.c needs this special function in xkeysym.c */
/* gtkwin.c needs this special function in xkeysym.c */
int keysym_to_unicode(int keysym);
/* Things uxstore.c needs from pterm.c */
/* Things uxstore.c needs from gtkwin.c */
char *x_get_default(const char *key);
/* Things uxstore.c provides to pterm.c */
/* Things uxstore.c provides to gtkwin.c */
void provide_xrm_string(char *string);
/* Function that {gtkapp,gtkmain}.c needs from ux{pterm,putty}.c. Does
* early process setup that varies between applications (e.g.
* pty_pre_init or sk_init), and is passed a boolean by the caller
* indicating whether this is an OS X style multi-session monolithic
* process or an ordinary Unix one-shot. */
void setup(bool single_session_in_this_process);
/*
* Per-application constants that affect behaviour of shared modules.
*/
/* Do we need an Event Log menu item? (yes for PuTTY, no for pterm) */
extern const bool use_event_log;
/* Do we need a New Session menu item? (yes for PuTTY, no for pterm) */
extern const bool new_session;
/* Do we need a Saved Sessions menu item? (yes for PuTTY, no for pterm) */
extern const bool saved_sessions;
/* When we Duplicate Session, do we need to double-check that the Conf
* is in a launchable state? (no for pterm, because conf_launchable
* returns an irrelevant answer, since we'll force use of the pty
* backend which ignores all the relevant settings) */
extern const bool dup_check_launchable;
/* In the Duplicate Session serialised data, do we send/receive an
* argv array after the main Conf? (yes for pterm, no for PuTTY) */
extern const bool use_pty_argv;
/*
* OS X environment munging: this is the prefix we expect to find on
* environment variable names that were changed by osxlaunch.
* Extracted from the command line of the OS X pterm main binary, and
* used in uxpty.c to restore the original environment before
* launching its subprocess.
*/
extern char *pty_osx_envrestore_prefix;
/* Things provided by uxcons.c */
struct termios;
void stderr_tty_init(void);
@ -360,4 +404,25 @@ Socket *make_fd_socket(int infd, int outfd, int inerrfd, Plug *plug);
#define DEFAULT_GTK_FONT "server:fixed"
#endif
#endif
/*
* uxpty.c.
*/
void pty_pre_init(void); /* pty+utmp setup before dropping privilege */
/* Pass in the argv[] for an instance of the pty backend created by
* the standard vtable constructor. Only called from (non-OSX) pterm,
* which will construct exactly one such instance, and initialises
* this from the command line. */
extern char **pty_argv;
/*
* gtkask.c.
*/
char *gtk_askpass_main(const char *display, const char *wintitle,
const char *prompt, bool *success);
/*
* uxsftpserver.c.
*/
extern const SftpServerVtable unix_live_sftpserver_vt;
#endif /* PUTTY_UNIX_H */

View File

@ -349,10 +349,6 @@ static char *askpass_gui(const char *prompt)
char *passphrase;
bool success;
/* in gtkask.c */
char *gtk_askpass_main(const char *display, const char *wintitle,
const char *prompt, bool *success);
passphrase = gtk_askpass_main(
display, "Pageant passphrase prompt", prompt, &success);
if (!success) {

View File

@ -43,8 +43,6 @@ char *make_default_wintitle(char *hostname)
void setup(bool single)
{
extern void pty_pre_init(void); /* declared in pty.c */
cmdline_tooltype = TOOLTYPE_NONNETWORK;
default_protocol = -1;

View File

@ -355,8 +355,6 @@ static bool longoptarg(const char *arg, const char *expected,
return false;
}
extern const SftpServerVtable unix_live_sftpserver_vt;
int main(int argc, char **argv)
{
int *fdlist;

View File

@ -23,12 +23,6 @@
#define SALT_FILENAME "salt"
#define SALT_SIZE 64
/*
* Functions provided by uxnet.c to help connection sharing.
*/
SockAddr *unix_sock_addr(const char *path);
Socket *new_unix_listener(SockAddr *listenaddr, Plug *plug);
static char *make_parentdir_name(void)
{
char *username, *parent;

View File

@ -49,8 +49,6 @@ static char *events_initial[LOGEVENT_INITIAL_MAX];
static char *events_circular[LOGEVENT_CIRCULAR_MAX];
static int ninitial = 0, ncircular = 0, circular_first = 0;
extern Conf *conf; /* defined in window.c */
#define PRINTER_DISABLED_STRING "None (printing disabled)"
void force_normal(HWND hwnd)
@ -799,7 +797,6 @@ static void win_gui_eventlog(LogPolicy *lp, const char *string)
static void win_gui_logging_error(LogPolicy *lp, const char *event)
{
extern Seat win_seat[1];
/* Send 'can't open log file' errors to the terminal window.
* (Marked as stderr, although terminal.c won't care.) */
seat_stderr(win_seat, event, strlen(event));

View File

@ -152,8 +152,6 @@ struct wm_netevent_params {
LPARAM lParam;
};
Conf *conf; /* exported to windlg.c */
static void conf_cache_data(void);
int cursor_type;
int vtmode;
@ -349,7 +347,8 @@ static const SeatVtable win_seat_vt = {
nullseat_get_windowid,
win_seat_get_window_pixel_size,
};
Seat win_seat[1] = {{ &win_seat_vt }};
static Seat win_seat_impl = { &win_seat_vt };
Seat *const win_seat = &win_seat_impl;
static void start_backend(void)
{

View File

@ -839,8 +839,6 @@ static void sk_net_set_frozen(Socket *s, bool is_frozen);
static const char *sk_net_socket_error(Socket *s);
static SocketPeerInfo *sk_net_peer_info(Socket *s);
extern char *do_select(SOCKET skt, bool startup);
static const SocketVtable NetSocket_sockvt = {
sk_net_plug,
sk_net_close,
@ -1790,7 +1788,7 @@ SOCKET next_socket(int *state)
return s ? s->s : INVALID_SOCKET;
}
extern bool socket_writable(SOCKET skt)
bool socket_writable(SOCKET skt)
{
NetSocket *s = find234(sktree, (void *)skt, cmpforsearch);

View File

@ -15,9 +15,6 @@
#include "winsecur.h"
Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,
Plug *plug, bool overlapped);
Socket *new_named_pipe_client(const char *pipename, Plug *plug)
{
HANDLE pipehandle;

View File

@ -15,9 +15,6 @@
#include "winsecur.h"
Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,
Plug *plug, bool overlapped);
typedef struct NamedPipeServerSocket {
/* Parameters for (repeated) creation of named pipe objects */
PSECURITY_DESCRIPTOR psd;
@ -120,12 +117,6 @@ static Socket *named_pipe_accept(accept_ctx_t ctx, Plug *plug)
return make_handle_socket(conn, conn, NULL, plug, true);
}
/*
* Dummy SockAddr *type which just holds a named pipe address. Only
* used for calling plug_log from named_pipe_accept_loop() here.
*/
SockAddr *sk_namedpipe_addr(const char *pipename);
static void named_pipe_accept_loop(NamedPipeServerSocket *ps,
bool got_one_already)
{

View File

@ -137,8 +137,6 @@ static void progress_update(void *param, int action, int phase, int iprogress)
}
}
extern const char ver[];
struct PassphraseProcStruct {
char **passphrase;
char *comment;

View File

@ -50,8 +50,6 @@
#define APPNAME "Pageant"
extern const char ver[];
static HWND keylist;
static HWND aboutbox;
static HMENU systray_menu, session_menu;

View File

@ -530,7 +530,6 @@ int main(int argc, char **argv)
} else if (n == WAIT_OBJECT_0 + nhandles) {
WSANETWORKEVENTS things;
SOCKET socket;
extern SOCKET first_socket(int *), next_socket(int *);
int i, socketstate;
/*

View File

@ -12,9 +12,6 @@
#include "network.h"
#include "proxy.h"
Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,
Plug *plug, bool overlapped);
Socket *platform_new_connection(SockAddr *addr, const char *hostname,
int port, bool privport,
bool oobinline, bool nodelay, bool keepalive,

View File

@ -535,7 +535,6 @@ int do_eventsel_loop(HANDLE other_event)
} else if (netindex >= 0 && n == WAIT_OBJECT_0 + netindex) {
WSANETWORKEVENTS things;
SOCKET socket;
extern SOCKET first_socket(int *), next_socket(int *);
int i, socketstate;
/*

View File

@ -115,9 +115,6 @@ static char *make_name(const char *prefix, const char *name)
return retname;
}
Socket *new_named_pipe_client(const char *pipename, Plug *plug);
Socket *new_named_pipe_listener(const char *pipename, Plug *plug);
int platform_ssh_share(const char *pi_name, Conf *conf,
Plug *downplug, Plug *upplug, Socket **sock,
char **logtext, char **ds_err, char **us_err,

View File

@ -235,13 +235,16 @@ void quit_help(HWND hwnd);
/*
* The terminal and logging context are notionally local to the
* Windows front end, but they must be shared between window.c and
* windlg.c. Likewise the Seat structure for the Windows GUI.
* windlg.c. Likewise the Seat structure for the Windows GUI, and the
* Conf for the main session..
*/
GLOBAL Terminal *term;
GLOBAL LogContext *logctx;
GLOBAL Conf *conf;
/*
* GUI seat methods in windlg.c.
* GUI seat methods in windlg.c, so that the vtable definition in
* window.c can refer to them.
*/
int win_seat_verify_ssh_host_key(
Seat *seat, const char *host, int port,
@ -254,6 +257,12 @@ int win_seat_confirm_weak_cached_hostkey(
Seat *seat, const char *algname, const char *betteralgs,
void (*callback)(void *ctx, int result), void *ctx);
/*
* The Windows GUI seat object itself, so that its methods can be
* called outside window.c.
*/
extern Seat *const win_seat;
/*
* Windows-specific clipboard helper function shared with windlg.c,
* which takes the data string in the system code page instead of
@ -303,7 +312,17 @@ void write_aclip(int clipboard, char *, int, bool);
/*
* Exports from winnet.c.
*/
extern void select_result(WPARAM, LPARAM);
/* Report an event notification from WSA*Select */
void select_result(WPARAM, LPARAM);
/* Enumerate all currently live OS-level SOCKETs */
SOCKET first_socket(int *);
SOCKET next_socket(int *);
/* Ask winnet.c whether we currently want to try to write to a SOCKET */
bool socket_writable(SOCKET skt);
/* Force a refresh of the SOCKET list by re-calling do_select for each one */
void socket_reselect_all(void);
/* Make a SockAddr which just holds a named pipe address. */
SockAddr *sk_namedpipe_addr(const char *pipename);
/*
* winnet.c dynamically loads WinSock 2 or WinSock 1 depending on
@ -331,9 +350,19 @@ DECL_WINDOWS_FUNCTION(GLOBAL, int, select,
fd_set FAR *, const struct timeval FAR *));
#endif
extern bool socket_writable(SOCKET skt);
/*
* Provided by each client of winnet.c, and called by winnet.c to turn
* on or off WSA*Select for a given socket.
*/
char *do_select(SOCKET skt, bool startup);
extern void socket_reselect_all(void);
/*
* Network-subsystem-related functions provided in other Windows modules.
*/
Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,
Plug *plug, bool overlapped); /* winhsock */
Socket *new_named_pipe_client(const char *pipename, Plug *plug); /* winnpc */
Socket *new_named_pipe_listener(const char *pipename, Plug *plug); /* winnps */
/*
* Exports from winctrls.c.