declaration cleanup
authorMischa POSLAWSKY <netris@shiar.org>
Mon, 5 Mar 2007 19:54:39 +0000 (20:54 +0100)
committerMischa POSLAWSKY <netris@shiar.org>
Mon, 5 Mar 2007 19:54:39 +0000 (20:54 +0100)
Avoid extern and superfluous declares; static wherever possible.

board.c
board.h
client.c
curses.c
curses.h
inet.c
inet.h
netris.h
server.c
util.h

diff --git a/board.c b/board.c
index 22efdc166ab1425e52eeba7d9c4174ba624266ac..cd1bc2834c7c0bb717474f869def09ab4a34898f 100644 (file)
--- 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 5f53aeebb952f9d58991d55d5a89036407f3202e..09212ffcedd62b1ce3bbc6718d6a7192dcf1de33 100644 (file)
--- 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);
index 6ed8087e7df9ad23c24af9c7fea8e850fec56724..013757261d907f97c0be72555406a4228baa3c50 100644 (file)
--- 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
index 5a90d2125fb189637d1b5a1b0b6a34fbf0f72e63..bd0949a2745f237f0d827417f887f272372ee021 100644 (file)
--- 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)
index 53650cac124695737d7dc2ea2132114468c4cd7d..84ff19b8f9f3d11530b7b83a84f9fee15620af67 100644 (file)
--- 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 36ba001272e2ea35610ce8e81f9e54feee2b5708..6ab0e66b0508ab65b46afbfbfb44762316cfec5e 100644 (file)
--- a/inet.c
+++ b/inet.c
 #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 fbeb0baa61be34efaf198b879cd192d6a967402d..fea28ed4a680e1f2ac6c5472b68642d6dddeeba3 100644 (file)
--- 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
 
index d6370a64faec8aa00bb1741311bd70c7c076ce55..28a4132403d7cdb66264aedf3e811d015e67bc95 100644 (file)
--- 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
 
index 814ac4e38c7dd744b649102ca6c4f4de5af4f99c..d33cf2444a8ad7181a900e978dc6f7aa98e1e13f 100644 (file)
--- 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 60bf69af3ed9fdb66e10c60b5f9d5c35b39fce38..4e2d712c37000cc3aa52d4b297062d36b119a0c9 100644 (file)
--- 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