From 75cab8143b83245f207db6dce43878827465b0fd Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 6 Oct 2000 11:42:30 +0000 Subject: [PATCH] Tighten up use of "static" throughout. Module-internal things should NOT be exported willy-nilly. It encourages people to use them. git-svn-id: svn://svn.tartarus.org/sgt/putty@677 cda61777-01e9-0310-a592-d414129be87e --- noise.c | 2 +- pageant.c | 24 ++++++++++++------------ scp.c | 10 +++++----- sizetip.c | 15 ++++++++------- ssh.c | 38 +++++++++++++++++++------------------- windlg.c | 51 ++++++++++++++++++++++++++++----------------------- 6 files changed, 73 insertions(+), 67 deletions(-) diff --git a/noise.c b/noise.c index ad257f56..af75f9d8 100644 --- a/noise.c +++ b/noise.c @@ -14,7 +14,7 @@ * GetSystemPowerStatus function. */ typedef BOOL (WINAPI *gsps_t)(LPSYSTEM_POWER_STATUS); -gsps_t gsps; +static gsps_t gsps; /* * This function is called once, at PuTTY startup, and will do some diff --git a/pageant.c b/pageant.c index 62f60db2..7f05e1b3 100644 --- a/pageant.c +++ b/pageant.c @@ -39,20 +39,20 @@ extern char ver[]; -HINSTANCE instance; -HWND hwnd; -HWND keylist; -HWND aboutbox; -HMENU systray_menu; +static HINSTANCE instance; +static HWND hwnd; +static HWND keylist; +static HWND aboutbox; +static HMENU systray_menu; -tree234 *rsakeys; +static tree234 *rsakeys; -int has_security; +static int has_security; typedef DWORD (WINAPI *gsi_fn_t) (HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION, PSID *, PSID *, PACL *, PACL *, PSECURITY_DESCRIPTOR *); -gsi_fn_t getsecurityinfo; +static gsi_fn_t getsecurityinfo; /* * We need this to link with the RSA code, because rsaencrypt() @@ -192,7 +192,7 @@ static int CALLBACK PassphraseProc(HWND hwnd, UINT msg, /* * Update the visible key list. */ -void keylist_update(void) { +static void keylist_update(void) { struct RSAKey *key; enum234 e; @@ -217,7 +217,7 @@ void keylist_update(void) { /* * This function loads a key from a file and adds it. */ -void add_keyfile(char *filename) { +static void add_keyfile(char *filename) { char passphrase[PASSPHRASE_MAXLEN]; struct RSAKey *key; int needs_pass; @@ -261,7 +261,7 @@ void add_keyfile(char *filename) { /* * This is the main agent function that answers messages. */ -void answer_msg(void *msg) { +static void answer_msg(void *msg) { unsigned char *p = msg; unsigned char *ret = msg; int type; @@ -432,7 +432,7 @@ void answer_msg(void *msg) { /* * Key comparison function for the 2-3-4 tree of RSA keys. */ -int cmpkeys(void *av, void *bv) { +static int cmpkeys(void *av, void *bv) { struct RSAKey *a = (struct RSAKey *)av; struct RSAKey *b = (struct RSAKey *)bv; Bignum am, bm; diff --git a/scp.c b/scp.c index 8f972763..ad1e69a4 100644 --- a/scp.c +++ b/scp.c @@ -81,13 +81,13 @@ void write_clip (void *data, int len) { } void term_deselect(void) { } /* GUI Adaptation - Sept 2000 */ -void send_msg(HWND h, UINT message, WPARAM wParam) +static void send_msg(HWND h, UINT message, WPARAM wParam) { while (!PostMessage( h, message, wParam, 0)) SleepEx(1000,TRUE); } -void tell_char(FILE *stream, char c) +static void tell_char(FILE *stream, char c) { if (!gui_mode) fputc(c, stream); @@ -99,7 +99,7 @@ void tell_char(FILE *stream, char c) } } -void tell_str(FILE *stream, char *str) +static void tell_str(FILE *stream, char *str) { unsigned int i; @@ -107,7 +107,7 @@ void tell_str(FILE *stream, char *str) tell_char(stream, str[i]); } -void tell_user(FILE *stream, char *fmt, ...) +static void tell_user(FILE *stream, char *fmt, ...) { char str[0x100]; /* Make the size big enough */ va_list ap; @@ -118,7 +118,7 @@ void tell_user(FILE *stream, char *fmt, ...) tell_str(stream, str); } -void gui_update_stats(char *name, unsigned long size, int percentage, time_t elapsed) +static void gui_update_stats(char *name, unsigned long size, int percentage, time_t elapsed) { unsigned int i; diff --git a/sizetip.c b/sizetip.c index b34b4f11..94407ae5 100644 --- a/sizetip.c +++ b/sizetip.c @@ -6,13 +6,14 @@ #include "putty.h" -ATOM tip_class = 0; +static ATOM tip_class = 0; -HFONT tip_font; -COLORREF tip_bg; -COLORREF tip_text; +static HFONT tip_font; +static COLORREF tip_bg; +static COLORREF tip_text; -LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg, + WPARAM wParam, LPARAM lParam) { switch (nMsg) { @@ -86,8 +87,8 @@ LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lPar return DefWindowProc(hWnd, nMsg, wParam, lParam); } -HWND tip_wnd = NULL; -int tip_enabled = 0; +static HWND tip_wnd = NULL; +static int tip_enabled = 0; void UpdateSizeTip(HWND src, int cx, int cy) { diff --git a/ssh.c b/ssh.c index 26cfbaa4..f0a26aad 100644 --- a/ssh.c +++ b/ssh.c @@ -810,7 +810,7 @@ static int ssh_versioncmp(char *a, char *b) { * state. */ #include -void sha_string(SHA_State *s, void *str, int len) { +static void sha_string(SHA_State *s, void *str, int len) { unsigned char lenblk[4]; PUT_32BIT(lenblk, len); SHA_Bytes(s, lenblk, 4); @@ -820,7 +820,7 @@ void sha_string(SHA_State *s, void *str, int len) { /* * SSH2 packet construction functions. */ -void ssh2_pkt_adddata(void *data, int len) { +static void ssh2_pkt_adddata(void *data, int len) { pktout.length += len; if (pktout.maxlen < pktout.length) { pktout.maxlen = pktout.length + 256; @@ -831,40 +831,40 @@ void ssh2_pkt_adddata(void *data, int len) { } memcpy(pktout.data+pktout.length-len, data, len); } -void ssh2_pkt_addbyte(unsigned char byte) { +static void ssh2_pkt_addbyte(unsigned char byte) { ssh2_pkt_adddata(&byte, 1); } -void ssh2_pkt_init(int pkt_type) { +static void ssh2_pkt_init(int pkt_type) { pktout.length = 5; ssh2_pkt_addbyte((unsigned char)pkt_type); } -void ssh2_pkt_addbool(unsigned char value) { +static void ssh2_pkt_addbool(unsigned char value) { ssh2_pkt_adddata(&value, 1); } -void ssh2_pkt_adduint32(unsigned long value) { +static void ssh2_pkt_adduint32(unsigned long value) { unsigned char x[4]; PUT_32BIT(x, value); ssh2_pkt_adddata(x, 4); } -void ssh2_pkt_addstring_start(void) { +static void ssh2_pkt_addstring_start(void) { ssh2_pkt_adduint32(0); pktout.savedpos = pktout.length; } -void ssh2_pkt_addstring_str(char *data) { +static void ssh2_pkt_addstring_str(char *data) { ssh2_pkt_adddata(data, strlen(data)); PUT_32BIT(pktout.data + pktout.savedpos - 4, pktout.length - pktout.savedpos); } -void ssh2_pkt_addstring_data(char *data, int len) { +static void ssh2_pkt_addstring_data(char *data, int len) { ssh2_pkt_adddata(data, len); PUT_32BIT(pktout.data + pktout.savedpos - 4, pktout.length - pktout.savedpos); } -void ssh2_pkt_addstring(char *data) { +static void ssh2_pkt_addstring(char *data) { ssh2_pkt_addstring_start(); ssh2_pkt_addstring_str(data); } -char *ssh2_mpint_fmt(Bignum b, int *len) { +static char *ssh2_mpint_fmt(Bignum b, int *len) { unsigned char *p; int i, n = b[0]; p = malloc(n * 2 + 1); @@ -882,7 +882,7 @@ char *ssh2_mpint_fmt(Bignum b, int *len) { *len = n*2+1-i; return p; } -void ssh2_pkt_addmp(Bignum b) { +static void ssh2_pkt_addmp(Bignum b) { unsigned char *p; int len; p = ssh2_mpint_fmt(b, &len); @@ -890,7 +890,7 @@ void ssh2_pkt_addmp(Bignum b) { ssh2_pkt_addstring_data(p, len); free(p); } -void ssh2_pkt_send(void) { +static void ssh2_pkt_send(void) { int cipherblk, maclen, padding, i; static unsigned long outgoing_sequence = 0; @@ -938,7 +938,7 @@ void bndebug(char *string, Bignum b) { } #endif -void sha_mpint(SHA_State *s, Bignum b) { +static void sha_mpint(SHA_State *s, Bignum b) { unsigned char *p; int len; p = ssh2_mpint_fmt(b, &len); @@ -949,7 +949,7 @@ void sha_mpint(SHA_State *s, Bignum b) { /* * SSH2 packet decode functions. */ -unsigned long ssh2_pkt_getuint32(void) { +static unsigned long ssh2_pkt_getuint32(void) { unsigned long value; if (pktin.length - pktin.savedpos < 4) return 0; /* arrgh, no way to decline (FIXME?) */ @@ -957,7 +957,7 @@ unsigned long ssh2_pkt_getuint32(void) { pktin.savedpos += 4; return value; } -void ssh2_pkt_getstring(char **p, int *length) { +static void ssh2_pkt_getstring(char **p, int *length) { *p = NULL; if (pktin.length - pktin.savedpos < 4) return; @@ -968,7 +968,7 @@ void ssh2_pkt_getstring(char **p, int *length) { *p = pktin.data+pktin.savedpos; pktin.savedpos += *length; } -Bignum ssh2_pkt_getmp(void) { +static Bignum ssh2_pkt_getmp(void) { char *p; int i, j, length; Bignum b; @@ -1776,7 +1776,7 @@ static void ssh1_protocol(unsigned char *in, int inlen, int ispkt) { /* * Utility routine for decoding comma-separated strings in KEXINIT. */ -int in_commasep_string(char *needle, char *haystack, int haylen) { +static int in_commasep_string(char *needle, char *haystack, int haylen) { int needlen = strlen(needle); while (1) { /* @@ -1803,7 +1803,7 @@ int in_commasep_string(char *needle, char *haystack, int haylen) { /* * SSH2 key creation method. */ -void ssh2_mkkey(Bignum K, char *H, char chr, char *keyspace) { +static void ssh2_mkkey(Bignum K, char *H, char chr, char *keyspace) { SHA_State s; /* First 20 bytes. */ SHA_Init(&s); diff --git a/windlg.c b/windlg.c index 47888f4f..bdd2d2f0 100644 --- a/windlg.c +++ b/windlg.c @@ -457,7 +457,7 @@ struct ctlpos { }; /* Used on self-constructed dialogs. */ -void ctlposinit(struct ctlpos *cp, HWND hwnd) { +static void ctlposinit(struct ctlpos *cp, HWND hwnd) { RECT r; cp->hwnd = hwnd; cp->units = GetWindowLong(hwnd, GWL_USERDATA); @@ -468,7 +468,7 @@ void ctlposinit(struct ctlpos *cp, HWND hwnd) { } /* Used on kosher dialogs. */ -void ctlposinit2(struct ctlpos *cp, HWND hwnd) { +static void ctlposinit2(struct ctlpos *cp, HWND hwnd) { RECT r; cp->hwnd = hwnd; r.left = r.top = 0; @@ -482,8 +482,9 @@ void ctlposinit2(struct ctlpos *cp, HWND hwnd) { cp->width = (r.right * 4) / (cp->units & 0xFFFF) - 2*GAPBETWEEN; } -void doctl(struct ctlpos *cp, RECT r, char *wclass, int wstyle, int exstyle, - char *wtext, int wid) { +static void doctl(struct ctlpos *cp, RECT r, + char *wclass, int wstyle, int exstyle, + char *wtext, int wid) { HWND ctl; /* * Note nonstandard use of RECT. This is deliberate: by @@ -507,7 +508,7 @@ void doctl(struct ctlpos *cp, RECT r, char *wclass, int wstyle, int exstyle, * Some edit boxes. Each one has a static above it. The percentages * of the horizontal space are provided. */ -void multiedit(struct ctlpos *cp, ...) { +static void multiedit(struct ctlpos *cp, ...) { RECT r; va_list ap; int percent, xpos; @@ -549,7 +550,8 @@ void multiedit(struct ctlpos *cp, ...) { * needed to line up some 2s and some 3s to look good in the same * panel). */ -void radioline(struct ctlpos *cp, char *text, int id, int nacross, ...) { +static void radioline(struct ctlpos *cp, + char *text, int id, int nacross, ...) { RECT r; va_list ap; int group; @@ -587,7 +589,7 @@ void radioline(struct ctlpos *cp, char *text, int id, int nacross, ...) { * A set of radio buttons on multiple lines, with a static above * them. */ -void radiobig(struct ctlpos *cp, char *text, int id, ...) { +static void radiobig(struct ctlpos *cp, char *text, int id, ...) { RECT r; va_list ap; int group; @@ -621,7 +623,7 @@ void radiobig(struct ctlpos *cp, char *text, int id, ...) { /* * A single standalone checkbox. */ -void checkbox(struct ctlpos *cp, char *text, int id) { +static void checkbox(struct ctlpos *cp, char *text, int id) { RECT r; r.left = GAPBETWEEN; r.top = cp->ypos; @@ -635,7 +637,8 @@ void checkbox(struct ctlpos *cp, char *text, int id) { /* * A button on the right hand side, with a static to its left. */ -void staticbtn(struct ctlpos *cp, char *stext, int sid, char *btext, int bid) { +static void staticbtn(struct ctlpos *cp, char *stext, int sid, + char *btext, int bid) { const int height = (PUSHBTNHEIGHT > STATICHEIGHT ? PUSHBTNHEIGHT : STATICHEIGHT); RECT r; @@ -662,7 +665,7 @@ void staticbtn(struct ctlpos *cp, char *stext, int sid, char *btext, int bid) { /* * An edit control on the right hand side, with a static to its left. */ -void staticedit(struct ctlpos *cp, char *stext, int sid, int eid) { +static void staticedit(struct ctlpos *cp, char *stext, int sid, int eid) { const int height = (EDITHEIGHT > STATICHEIGHT ? EDITHEIGHT : STATICHEIGHT); RECT r; @@ -689,7 +692,8 @@ void staticedit(struct ctlpos *cp, char *stext, int sid, int eid) { /* * A tab-control substitute when a real tab control is unavailable. */ -void ersatztab(struct ctlpos *cp, char *stext, int sid, int lid, int s2id) { +static void ersatztab(struct ctlpos *cp, char *stext, int sid, + int lid, int s2id) { const int height = (COMBOHEIGHT > STATICHEIGHT ? COMBOHEIGHT : STATICHEIGHT); RECT r; @@ -727,8 +731,8 @@ void ersatztab(struct ctlpos *cp, char *stext, int sid, int lid, int s2id) { * A static line, followed by an edit control on the left hand side * and a button on the right. */ -void editbutton(struct ctlpos *cp, char *stext, int sid, - int eid, char *btext, int bid) { +static void editbutton(struct ctlpos *cp, char *stext, int sid, + int eid, char *btext, int bid) { const int height = (EDITHEIGHT > PUSHBTNHEIGHT ? EDITHEIGHT : PUSHBTNHEIGHT); RECT r; @@ -766,8 +770,8 @@ void editbutton(struct ctlpos *cp, char *stext, int sid, * that a list box. To the right of the list box, a column of * buttons. */ -void sesssaver(struct ctlpos *cp, char *text, - int staticid, int editid, int listid, ...) { +static void sesssaver(struct ctlpos *cp, char *text, + int staticid, int editid, int listid, ...) { RECT r; va_list ap; int lwid, rwid, rpos; @@ -832,10 +836,11 @@ void sesssaver(struct ctlpos *cp, char *text, * static line first; then a pair of edit boxes with associated * statics, and two buttons; then a list box. */ -void envsetter(struct ctlpos *cp, char *stext, int sid, - char *e1stext, int e1sid, int e1id, - char *e2stext, int e2sid, int e2id, - int listid, char *b1text, int b1id, char *b2text, int b2id) { +static void envsetter(struct ctlpos *cp, char *stext, int sid, + char *e1stext, int e1sid, int e1id, + char *e2stext, int e2sid, int e2id, + int listid, + char *b1text, int b1id, char *b2text, int b2id) { RECT r; const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ? STATICHEIGHT : @@ -899,8 +904,8 @@ void envsetter(struct ctlpos *cp, char *stext, int sid, * static, then a list, then a line containing a * button-and-static-and-edit. */ -void charclass(struct ctlpos *cp, char *stext, int sid, int listid, - char *btext, int bid, int eid, char *s2text, int s2id) { +static void charclass(struct ctlpos *cp, char *stext, int sid, int listid, + char *btext, int bid, int eid, char *s2text, int s2id) { RECT r; const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ? STATICHEIGHT : @@ -959,8 +964,8 @@ void charclass(struct ctlpos *cp, char *stext, int sid, int listid, * then on the left, a list box, and on the right, a sequence of * two-part statics followed by a button. */ -void colouredit(struct ctlpos *cp, char *stext, int sid, int listid, - char *btext, int bid, ...) { +static void colouredit(struct ctlpos *cp, char *stext, int sid, int listid, + char *btext, int bid, ...) { RECT r; int y; va_list ap; -- 2.11.0