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

Tighten up use of "static" throughout. Module-internal things should NOT

be exported willy-nilly. It encourages people to use them.

[originally from svn r677]
This commit is contained in:
Simon Tatham 2000-10-06 11:42:30 +00:00
parent 38a6322cec
commit 8c169b0c6d
6 changed files with 73 additions and 67 deletions

View File

@ -14,7 +14,7 @@
* GetSystemPowerStatus function. * GetSystemPowerStatus function.
*/ */
typedef BOOL (WINAPI *gsps_t)(LPSYSTEM_POWER_STATUS); 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 * This function is called once, at PuTTY startup, and will do some

View File

@ -39,20 +39,20 @@
extern char ver[]; extern char ver[];
HINSTANCE instance; static HINSTANCE instance;
HWND hwnd; static HWND hwnd;
HWND keylist; static HWND keylist;
HWND aboutbox; static HWND aboutbox;
HMENU systray_menu; static HMENU systray_menu;
tree234 *rsakeys; static tree234 *rsakeys;
int has_security; static int has_security;
typedef DWORD (WINAPI *gsi_fn_t) typedef DWORD (WINAPI *gsi_fn_t)
(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION, (HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
PSID *, PSID *, PACL *, PACL *, PSID *, PSID *, PACL *, PACL *,
PSECURITY_DESCRIPTOR *); PSECURITY_DESCRIPTOR *);
gsi_fn_t getsecurityinfo; static gsi_fn_t getsecurityinfo;
/* /*
* We need this to link with the RSA code, because rsaencrypt() * 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. * Update the visible key list.
*/ */
void keylist_update(void) { static void keylist_update(void) {
struct RSAKey *key; struct RSAKey *key;
enum234 e; enum234 e;
@ -217,7 +217,7 @@ void keylist_update(void) {
/* /*
* This function loads a key from a file and adds it. * 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]; char passphrase[PASSPHRASE_MAXLEN];
struct RSAKey *key; struct RSAKey *key;
int needs_pass; int needs_pass;
@ -261,7 +261,7 @@ void add_keyfile(char *filename) {
/* /*
* This is the main agent function that answers messages. * 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 *p = msg;
unsigned char *ret = msg; unsigned char *ret = msg;
int type; int type;
@ -432,7 +432,7 @@ void answer_msg(void *msg) {
/* /*
* Key comparison function for the 2-3-4 tree of RSA keys. * 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 *a = (struct RSAKey *)av;
struct RSAKey *b = (struct RSAKey *)bv; struct RSAKey *b = (struct RSAKey *)bv;
Bignum am, bm; Bignum am, bm;

10
scp.c
View File

@ -81,13 +81,13 @@ void write_clip (void *data, int len) { }
void term_deselect(void) { } void term_deselect(void) { }
/* GUI Adaptation - Sept 2000 */ /* 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)) while (!PostMessage( h, message, wParam, 0))
SleepEx(1000,TRUE); SleepEx(1000,TRUE);
} }
void tell_char(FILE *stream, char c) static void tell_char(FILE *stream, char c)
{ {
if (!gui_mode) if (!gui_mode)
fputc(c, stream); 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; unsigned int i;
@ -107,7 +107,7 @@ void tell_str(FILE *stream, char *str)
tell_char(stream, str[i]); 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 */ char str[0x100]; /* Make the size big enough */
va_list ap; va_list ap;
@ -118,7 +118,7 @@ void tell_user(FILE *stream, char *fmt, ...)
tell_str(stream, str); 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; unsigned int i;

View File

@ -6,13 +6,14 @@
#include "putty.h" #include "putty.h"
ATOM tip_class = 0; static ATOM tip_class = 0;
HFONT tip_font; static HFONT tip_font;
COLORREF tip_bg; static COLORREF tip_bg;
COLORREF tip_text; 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) { switch (nMsg) {
@ -86,8 +87,8 @@ LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lPar
return DefWindowProc(hWnd, nMsg, wParam, lParam); return DefWindowProc(hWnd, nMsg, wParam, lParam);
} }
HWND tip_wnd = NULL; static HWND tip_wnd = NULL;
int tip_enabled = 0; static int tip_enabled = 0;
void UpdateSizeTip(HWND src, int cx, int cy) void UpdateSizeTip(HWND src, int cx, int cy)
{ {

38
ssh.c
View File

@ -810,7 +810,7 @@ static int ssh_versioncmp(char *a, char *b) {
* state. * state.
*/ */
#include <stdio.h> #include <stdio.h>
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]; unsigned char lenblk[4];
PUT_32BIT(lenblk, len); PUT_32BIT(lenblk, len);
SHA_Bytes(s, lenblk, 4); SHA_Bytes(s, lenblk, 4);
@ -820,7 +820,7 @@ void sha_string(SHA_State *s, void *str, int len) {
/* /*
* SSH2 packet construction functions. * SSH2 packet construction functions.
*/ */
void ssh2_pkt_adddata(void *data, int len) { static void ssh2_pkt_adddata(void *data, int len) {
pktout.length += len; pktout.length += len;
if (pktout.maxlen < pktout.length) { if (pktout.maxlen < pktout.length) {
pktout.maxlen = pktout.length + 256; 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); 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); ssh2_pkt_adddata(&byte, 1);
} }
void ssh2_pkt_init(int pkt_type) { static void ssh2_pkt_init(int pkt_type) {
pktout.length = 5; pktout.length = 5;
ssh2_pkt_addbyte((unsigned char)pkt_type); 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); ssh2_pkt_adddata(&value, 1);
} }
void ssh2_pkt_adduint32(unsigned long value) { static void ssh2_pkt_adduint32(unsigned long value) {
unsigned char x[4]; unsigned char x[4];
PUT_32BIT(x, value); PUT_32BIT(x, value);
ssh2_pkt_adddata(x, 4); ssh2_pkt_adddata(x, 4);
} }
void ssh2_pkt_addstring_start(void) { static void ssh2_pkt_addstring_start(void) {
ssh2_pkt_adduint32(0); ssh2_pkt_adduint32(0);
pktout.savedpos = pktout.length; 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)); ssh2_pkt_adddata(data, strlen(data));
PUT_32BIT(pktout.data + pktout.savedpos - 4, PUT_32BIT(pktout.data + pktout.savedpos - 4,
pktout.length - pktout.savedpos); 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); ssh2_pkt_adddata(data, len);
PUT_32BIT(pktout.data + pktout.savedpos - 4, PUT_32BIT(pktout.data + pktout.savedpos - 4,
pktout.length - pktout.savedpos); pktout.length - pktout.savedpos);
} }
void ssh2_pkt_addstring(char *data) { static void ssh2_pkt_addstring(char *data) {
ssh2_pkt_addstring_start(); ssh2_pkt_addstring_start();
ssh2_pkt_addstring_str(data); 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; unsigned char *p;
int i, n = b[0]; int i, n = b[0];
p = malloc(n * 2 + 1); p = malloc(n * 2 + 1);
@ -882,7 +882,7 @@ char *ssh2_mpint_fmt(Bignum b, int *len) {
*len = n*2+1-i; *len = n*2+1-i;
return p; return p;
} }
void ssh2_pkt_addmp(Bignum b) { static void ssh2_pkt_addmp(Bignum b) {
unsigned char *p; unsigned char *p;
int len; int len;
p = ssh2_mpint_fmt(b, &len); p = ssh2_mpint_fmt(b, &len);
@ -890,7 +890,7 @@ void ssh2_pkt_addmp(Bignum b) {
ssh2_pkt_addstring_data(p, len); ssh2_pkt_addstring_data(p, len);
free(p); free(p);
} }
void ssh2_pkt_send(void) { static void ssh2_pkt_send(void) {
int cipherblk, maclen, padding, i; int cipherblk, maclen, padding, i;
static unsigned long outgoing_sequence = 0; static unsigned long outgoing_sequence = 0;
@ -938,7 +938,7 @@ void bndebug(char *string, Bignum b) {
} }
#endif #endif
void sha_mpint(SHA_State *s, Bignum b) { static void sha_mpint(SHA_State *s, Bignum b) {
unsigned char *p; unsigned char *p;
int len; int len;
p = ssh2_mpint_fmt(b, &len); p = ssh2_mpint_fmt(b, &len);
@ -949,7 +949,7 @@ void sha_mpint(SHA_State *s, Bignum b) {
/* /*
* SSH2 packet decode functions. * SSH2 packet decode functions.
*/ */
unsigned long ssh2_pkt_getuint32(void) { static unsigned long ssh2_pkt_getuint32(void) {
unsigned long value; unsigned long value;
if (pktin.length - pktin.savedpos < 4) if (pktin.length - pktin.savedpos < 4)
return 0; /* arrgh, no way to decline (FIXME?) */ return 0; /* arrgh, no way to decline (FIXME?) */
@ -957,7 +957,7 @@ unsigned long ssh2_pkt_getuint32(void) {
pktin.savedpos += 4; pktin.savedpos += 4;
return value; return value;
} }
void ssh2_pkt_getstring(char **p, int *length) { static void ssh2_pkt_getstring(char **p, int *length) {
*p = NULL; *p = NULL;
if (pktin.length - pktin.savedpos < 4) if (pktin.length - pktin.savedpos < 4)
return; return;
@ -968,7 +968,7 @@ void ssh2_pkt_getstring(char **p, int *length) {
*p = pktin.data+pktin.savedpos; *p = pktin.data+pktin.savedpos;
pktin.savedpos += *length; pktin.savedpos += *length;
} }
Bignum ssh2_pkt_getmp(void) { static Bignum ssh2_pkt_getmp(void) {
char *p; char *p;
int i, j, length; int i, j, length;
Bignum b; 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. * 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); int needlen = strlen(needle);
while (1) { while (1) {
/* /*
@ -1803,7 +1803,7 @@ int in_commasep_string(char *needle, char *haystack, int haylen) {
/* /*
* SSH2 key creation method. * 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; SHA_State s;
/* First 20 bytes. */ /* First 20 bytes. */
SHA_Init(&s); SHA_Init(&s);

View File

@ -457,7 +457,7 @@ struct ctlpos {
}; };
/* Used on self-constructed dialogs. */ /* Used on self-constructed dialogs. */
void ctlposinit(struct ctlpos *cp, HWND hwnd) { static void ctlposinit(struct ctlpos *cp, HWND hwnd) {
RECT r; RECT r;
cp->hwnd = hwnd; cp->hwnd = hwnd;
cp->units = GetWindowLong(hwnd, GWL_USERDATA); cp->units = GetWindowLong(hwnd, GWL_USERDATA);
@ -468,7 +468,7 @@ void ctlposinit(struct ctlpos *cp, HWND hwnd) {
} }
/* Used on kosher dialogs. */ /* Used on kosher dialogs. */
void ctlposinit2(struct ctlpos *cp, HWND hwnd) { static void ctlposinit2(struct ctlpos *cp, HWND hwnd) {
RECT r; RECT r;
cp->hwnd = hwnd; cp->hwnd = hwnd;
r.left = r.top = 0; r.left = r.top = 0;
@ -482,7 +482,8 @@ void ctlposinit2(struct ctlpos *cp, HWND hwnd) {
cp->width = (r.right * 4) / (cp->units & 0xFFFF) - 2*GAPBETWEEN; cp->width = (r.right * 4) / (cp->units & 0xFFFF) - 2*GAPBETWEEN;
} }
void doctl(struct ctlpos *cp, RECT r, char *wclass, int wstyle, int exstyle, static void doctl(struct ctlpos *cp, RECT r,
char *wclass, int wstyle, int exstyle,
char *wtext, int wid) { char *wtext, int wid) {
HWND ctl; HWND ctl;
/* /*
@ -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 * Some edit boxes. Each one has a static above it. The percentages
* of the horizontal space are provided. * of the horizontal space are provided.
*/ */
void multiedit(struct ctlpos *cp, ...) { static void multiedit(struct ctlpos *cp, ...) {
RECT r; RECT r;
va_list ap; va_list ap;
int percent, xpos; 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 * needed to line up some 2s and some 3s to look good in the same
* panel). * 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; RECT r;
va_list ap; va_list ap;
int group; 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 * A set of radio buttons on multiple lines, with a static above
* them. * them.
*/ */
void radiobig(struct ctlpos *cp, char *text, int id, ...) { static void radiobig(struct ctlpos *cp, char *text, int id, ...) {
RECT r; RECT r;
va_list ap; va_list ap;
int group; int group;
@ -621,7 +623,7 @@ void radiobig(struct ctlpos *cp, char *text, int id, ...) {
/* /*
* A single standalone checkbox. * 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; RECT r;
r.left = GAPBETWEEN; r.top = cp->ypos; 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. * 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 ? const int height = (PUSHBTNHEIGHT > STATICHEIGHT ?
PUSHBTNHEIGHT : STATICHEIGHT); PUSHBTNHEIGHT : STATICHEIGHT);
RECT r; 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. * 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 ? const int height = (EDITHEIGHT > STATICHEIGHT ?
EDITHEIGHT : STATICHEIGHT); EDITHEIGHT : STATICHEIGHT);
RECT r; 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. * 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 ? const int height = (COMBOHEIGHT > STATICHEIGHT ?
COMBOHEIGHT : STATICHEIGHT); COMBOHEIGHT : STATICHEIGHT);
RECT r; RECT r;
@ -727,7 +731,7 @@ 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 * A static line, followed by an edit control on the left hand side
* and a button on the right. * and a button on the right.
*/ */
void editbutton(struct ctlpos *cp, char *stext, int sid, static void editbutton(struct ctlpos *cp, char *stext, int sid,
int eid, char *btext, int bid) { int eid, char *btext, int bid) {
const int height = (EDITHEIGHT > PUSHBTNHEIGHT ? const int height = (EDITHEIGHT > PUSHBTNHEIGHT ?
EDITHEIGHT : PUSHBTNHEIGHT); EDITHEIGHT : PUSHBTNHEIGHT);
@ -766,7 +770,7 @@ void editbutton(struct ctlpos *cp, char *stext, int sid,
* that a list box. To the right of the list box, a column of * that a list box. To the right of the list box, a column of
* buttons. * buttons.
*/ */
void sesssaver(struct ctlpos *cp, char *text, static void sesssaver(struct ctlpos *cp, char *text,
int staticid, int editid, int listid, ...) { int staticid, int editid, int listid, ...) {
RECT r; RECT r;
va_list ap; va_list ap;
@ -832,10 +836,11 @@ void sesssaver(struct ctlpos *cp, char *text,
* static line first; then a pair of edit boxes with associated * static line first; then a pair of edit boxes with associated
* statics, and two buttons; then a list box. * statics, and two buttons; then a list box.
*/ */
void envsetter(struct ctlpos *cp, char *stext, int sid, static void envsetter(struct ctlpos *cp, char *stext, int sid,
char *e1stext, int e1sid, int e1id, char *e1stext, int e1sid, int e1id,
char *e2stext, int e2sid, int e2id, char *e2stext, int e2sid, int e2id,
int listid, char *b1text, int b1id, char *b2text, int b2id) { int listid,
char *b1text, int b1id, char *b2text, int b2id) {
RECT r; RECT r;
const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ? const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ?
STATICHEIGHT : STATICHEIGHT :
@ -899,7 +904,7 @@ void envsetter(struct ctlpos *cp, char *stext, int sid,
* static, then a list, then a line containing a * static, then a list, then a line containing a
* button-and-static-and-edit. * button-and-static-and-edit.
*/ */
void charclass(struct ctlpos *cp, char *stext, int sid, int listid, static void charclass(struct ctlpos *cp, char *stext, int sid, int listid,
char *btext, int bid, int eid, char *s2text, int s2id) { char *btext, int bid, int eid, char *s2text, int s2id) {
RECT r; RECT r;
const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ? const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ?
@ -959,7 +964,7 @@ 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 * then on the left, a list box, and on the right, a sequence of
* two-part statics followed by a button. * two-part statics followed by a button.
*/ */
void colouredit(struct ctlpos *cp, char *stext, int sid, int listid, static void colouredit(struct ctlpos *cp, char *stext, int sid, int listid,
char *btext, int bid, ...) { char *btext, int bid, ...) {
RECT r; RECT r;
int y; int y;