From 406e72f6bc3be827e1202d817677e8af093231dc Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Mon, 5 Mar 2007 20:54:39 +0100 Subject: [PATCH] declaration cleanup Avoid extern and superfluous declares; static wherever possible. --- board.c | 2 +- board.h | 1 - client.c | 18 +++++++++--------- curses.c | 18 +++++++++--------- curses.h | 11 ++++------- inet.c | 8 ++++---- inet.h | 4 +--- netris.h | 2 -- server.c | 24 ++++++++++++------------ util.h | 1 - 10 files changed, 40 insertions(+), 49 deletions(-) diff --git a/board.c b/board.c index 22efdc1..cd1bc28 100644 --- a/board.c +++ b/board.c @@ -149,7 +149,7 @@ unsigned char GetBlock(int scr, int y, int x) return board[scr][y][x]; } -void SetBlock(int scr, int y, int x, unsigned char type) +static void SetBlock(int scr, int y, int x, unsigned char type) { if (y >= 0 && y < Players[scr].boardHeight && x >= 0 && x < Players[scr].boardWidth) { diff --git a/board.h b/board.h index 5f53aee..09212ff 100644 --- a/board.h +++ b/board.h @@ -8,7 +8,6 @@ extern int ShapeIterate(char s, int scr, int y, int x, ShapeDrawFunc func); extern char ChooseOption(float options[7]); extern void ClearField(int scr); extern unsigned char GetBlock(int scr, int y, int x); -extern void SetBlock(int scr, int y, int x, unsigned char type); extern int RefreshBoard(int scr); extern int GlanceFunc(int scr, int y, int x, unsigned char type); extern int ShadowFunc(int scr, int y, int x, unsigned char type); diff --git a/client.c b/client.c index 6ed8087..0137572 100644 --- a/client.c +++ b/client.c @@ -77,7 +77,7 @@ static bool paused = 0; static char lastadd; -void handle_setkeys(char *newKeys) +static void handle_setkeys(char *newKeys) { int i, k, ch; char used[256]; @@ -113,7 +113,7 @@ void handle_setkeys(char *newKeys) exit(1); } -void Usage(void) +static void Usage(void) { Header(); fprintf(stderr, @@ -138,7 +138,7 @@ void Usage(void) ); } -void handle_arg(char tag, char *value) +static void handle_arg(char tag, char *value) { switch (tag) { case 'a': //ascii @@ -189,7 +189,7 @@ void handle_arg(char tag, char *value) } } -void handle_conffile(char *filename) +static void handle_conffile(char *filename) { FILE *file_in; char buf[513]; @@ -222,7 +222,7 @@ void handle_conffile(char *filename) } //defaults } -int game_piece(int scr, char shape) +static int game_piece(int scr, char shape) { Players[scr].score.pieces++; { @@ -242,7 +242,7 @@ int game_piece(int scr, char shape) return 1; } -void game_setpaused(void) +static void game_setpaused(void) { //check whether anyone paused the game int i; @@ -251,7 +251,7 @@ void game_setpaused(void) paused |= (Players[i].flags & SCF_paused) != 0; } -void game_reset(void) +static void game_reset(void) { //init new game int i; @@ -274,7 +274,7 @@ void game_reset(void) InitFields(); } -void game_clear(int scr) +static void game_clear(int scr) { //check for full lines int linesCleared; int linevalues[] = { 40, 100, 400, 1200, }; //= 50*lines! - 10*(lines==1) @@ -318,7 +318,7 @@ void game_clear(int scr) } //lines cleared } -void game_loop(void) +static void game_loop(void) { bool changed = 0; short gameStatus = 2; //2=loop; 1=new piece; 0=quit diff --git a/curses.c b/curses.c index 5a90d21..bd0949a 100644 --- a/curses.c +++ b/curses.c @@ -50,8 +50,8 @@ static int haveColor; int PlayerDisp[MAX_SCREENS]; #define MSG_HEIGHT 64 //max history -char *message[MSG_HEIGHT]; -char messages[MSG_HEIGHT][MSG_WIDTH]; +static char *message[MSG_HEIGHT]; +static char messages[MSG_HEIGHT][MSG_WIDTH]; static char *term_vi; /* String to make cursor invisible */ static char *term_ve; /* String to make cursor visible */ @@ -134,7 +134,7 @@ void CleanupScreens(void) OutputTermStr(term_ve, 1); } -void GetTermcapInfo(void) +static void GetTermcapInfo(void) { char *term, *buf, *data; int bufSize = 8192; @@ -191,7 +191,7 @@ void GetTermcapInfo(void) term_vi = term_ve = NULL; } -void OutputTermStr(char *str, int flush) +static void OutputTermStr(char *str, int flush) { if (str) { fputs(str, stdout); @@ -199,7 +199,7 @@ void OutputTermStr(char *str, int flush) } } -void DrawTitle(void) +static void DrawTitle(void) { int rows, cols; char *s; @@ -337,7 +337,7 @@ void InitFields(void) DrawField(scr); } -void DisplayMessage(char *p) +static void DisplayMessage(char *p) { char s[MSG_WIDTH]; char *psearch; @@ -397,7 +397,7 @@ void Messagetype(char c, int x, char *s) wrefresh(msgwin); } -void PlotBlock1(int y, int x, unsigned char type) +static void PlotBlock1(int y, int x, unsigned char type) { //display block on screen move(y, x); if (type == BT_none) addstr(" "); @@ -466,7 +466,7 @@ void PlotBlock1(int y, int x, unsigned char type) #endif } //display one brick } -void PlotBlock1S(int y, int x, unsigned char type) +static void PlotBlock1S(int y, int x, unsigned char type) { //display block small move(y, x); if (type == BT_none) addch(' '); @@ -590,7 +590,7 @@ void ScheduleFullRedraw(void) touchwin(stdscr); } -void CatchWinCh(int sig) +static void CatchWinCh(int sig) { //handle window resize endwin(); //exit curses refresh(); //and reinit display (with different sizes) diff --git a/curses.h b/curses.h index 53650ca..84ff19b 100644 --- a/curses.h +++ b/curses.h @@ -5,17 +5,14 @@ extern int PlayerDisp[MAX_SCREENS]; extern void InitScreens(void); extern void CleanupScreens(void); -extern void GetTermcapInfo(void); -extern void OutputTermStr(char *str, int flush); -extern void DrawTitle(void); +static void GetTermcapInfo(void); +static void OutputTermStr(char *str, int flush); extern void DrawBox(int x1, int y1, int x2, int y2); extern void DrawField(int scr); extern void InitFields(void); -extern void DisplayMessage(char *p); +static void DisplayMessage(char *p); extern void Messagef(char *fmt, ...); extern void Messagetype(char c, int x, char *s); -extern void PlotBlock1(int y, int x, unsigned char type); -extern void PlotBlock1S(int y, int x, unsigned char type); extern void PlotBlock(int scr, int y, int x, unsigned char type); extern void PlotBlockXY(int y, int x, unsigned char type); extern void ShowScore(int scr, struct _Score score); @@ -23,7 +20,7 @@ extern void FieldMessage(int playa, char *message); extern void ShowPause(int playa); extern void ShowTime(void); extern void ScheduleFullRedraw(void); -extern void CatchWinCh(int sig); +static void CatchWinCh(int sig); #endif //__CURSES_H diff --git a/inet.c b/inet.c index 36ba001..6ab0e66 100644 --- a/inet.c +++ b/inet.c @@ -34,15 +34,15 @@ #define HEADER_SIZE sizeof(netint2[2]) #define HEADER_SIZE3 sizeof(netint4[3]) -MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event); -EventGenRec netGen = { +static MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event); +static EventGenRec netGen = { NULL, 0, FT_read, -1, NetGenFunc, EM_net, 0, "\0", 0, HEADER_SIZE3 }; static sigjmp_buf close_env; -void CatchInt(int sig) +static void CatchInt(int sig) { siglongjmp(close_env, 1); } @@ -141,7 +141,7 @@ void HandShake(void) } -MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event) +static MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event) { //receive int result; short uid, type, size; diff --git a/inet.h b/inet.h index fbeb0ba..fea28ed 100644 --- a/inet.h +++ b/inet.h @@ -1,12 +1,10 @@ #ifndef __INET_H #define __INET_H -extern MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event); extern int InitiateConnection(char *hostStr, short port); extern void HandShake(void); -extern MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event); extern void SendPacket(short uid, NetPacketType type, int size, void *data); -extern void CloseNet(void); +static void CloseNet(void); #endif //__INET_H diff --git a/netris.h b/netris.h index d6370a6..28a4132 100644 --- a/netris.h +++ b/netris.h @@ -146,8 +146,6 @@ typedef struct _EventGenRec { int bufSize, bufGoal; } EventGenRec; -MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event); - /* NP_startConn flags */ #define SCF_paused 1 diff --git a/server.c b/server.c index 814ac4e..d33cf24 100644 --- a/server.c +++ b/server.c @@ -59,7 +59,7 @@ static char verbose = 0; struct sockaddr_in addr; -MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event); +static MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event); static EventGenRec netGen[MAX_SCREENS] = { { NULL, 0, FT_read, -1, NetGenFunc, EM_net, 0, "\0", 0, HEADER_SIZE } }; @@ -79,7 +79,7 @@ static EventGenRec *nextGen = &alarmGen; static sigjmp_buf close_env; -void SendPacketTo(short playa, short uid, NetPacketType type, int size, void *data) +static void SendPacketTo(short playa, short uid, NetPacketType type, int size, void *data) { //send to someone netint4 header[3]; @@ -101,7 +101,7 @@ static MyEventType AlarmGenFunc(EventGenRec *gen, MyEvent *event) return E_alarm; } -void SCloseNet(short playa) +static void SCloseNet(short playa) { //kick some connection's ass! MyEvent event; @@ -117,7 +117,7 @@ void SCloseNet(short playa) RemoveEventGen(&netGen[playa]); } -void CloseNets(void) +static void CloseNets(void) { //nou oogjes dicht en snaveltjes toe int i; @@ -127,7 +127,7 @@ void CloseNets(void) fprintf(stderr, MSG_SERVER_CLOSE_ALL_DONE "\n\n"); } -MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event) +static MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event) { //receive int result; short uid, type, size; @@ -204,7 +204,7 @@ static MyEventType ConnGenFunc(EventGenRec *gen, MyEvent *event) return E_connect; } -void CountPlayers(void) +static void CountPlayers(void) { //count number of players/teams int i, j; playercount = 0; @@ -219,7 +219,7 @@ void CountPlayers(void) } //player alive } -int StartServer(void) +static int StartServer(void) { MyEvent event; netint2 currentpiece[MAX_SCREENS]; @@ -424,12 +424,12 @@ int StartServer(void) } -void SHeader(void) +static void SHeader(void) { fprintf(stderr, MSG_SERVER_TITLE "\n\n", version_string); } -void SUsage(void) +static void SUsage(void) { SHeader(); fprintf(stderr, @@ -450,7 +450,7 @@ void SUsage(void) ); } -void HandleOption(char tag, char *value) +static void HandleOption(char tag, char *value) { switch (tag) { case 'v': //verbose @@ -489,7 +489,7 @@ void HandleOption(char tag, char *value) } } -void ReadConf(char *filename) +static void ReadConf(char *filename) { FILE *file_in; char buf[513]; @@ -524,7 +524,7 @@ void ReadConf(char *filename) } -void CatchInt(int sig) +static void CatchInt(int sig) { siglongjmp(close_env, 1); } diff --git a/util.h b/util.h index 60bf69a..4e2d712 100644 --- a/util.h +++ b/util.h @@ -30,7 +30,6 @@ extern void RestoreSignals(MySigSet *saved, MySigSet *set); extern void AddEventGen(EventGenRec *gen); extern void RemoveEventGen(EventGenRec *gen); extern MyEventType WaitMyEvent(MyEvent *event, int mask); -extern void CatchInt(int sig); #endif //__UTIL_H -- 2.30.0