From 3e4350c1595363566ed599dd43706ef5fa817f82 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 21 Aug 2016 20:33:43 +0100 Subject: [PATCH] build-sys: tell function locality explicitly Most of the function prototypes in header files are indeed external, with few exceptions that can be set to local scope with static key word. Additionally get rid of net_duplicate() prototype that does not exist anywhere. --- asn.c | 20 +++++----- asn.h | 10 ++--- curses.c | 29 +++++++------- display.c | 20 +++++----- display.h | 20 +++++----- dns.c | 31 +++++++-------- dns.h | 22 +++++------ gtk.c | 66 +++++++++++++++---------------- mtr-curses.h | 10 ++--- mtr-gtk.h | 12 +++--- mtr.c | 10 ++--- mtr.h | 2 +- net.c | 109 ++++++++++++++++++++++++++------------------------- net.h | 100 +++++++++++++++++++++++----------------------- raw.c | 6 +-- raw.h | 6 +-- report.c | 22 +++++------ report.h | 20 +++++----- select.c | 2 +- select.h | 2 +- split.c | 8 ++-- split.h | 8 ++-- 22 files changed, 266 insertions(+), 269 deletions(-) diff --git a/asn.c b/asn.c index 833ec4f..dbb5926 100644 --- a/asn.c +++ b/asn.c @@ -74,7 +74,7 @@ char txtrec[NAMELEN + 1]; // without hash: txtrec items_t* items = &items_a; -char *ipinfo_lookup(const char *domain) { +static char *ipinfo_lookup(const char *domain) { unsigned char answer[PACKETSZ], *pt; char host[128]; char *txt; @@ -147,7 +147,7 @@ char *ipinfo_lookup(const char *domain) { return txt; } -char* trimsep(char *s) { +static char* trimsep(char *s) { int l; char *p = s; while (*p == ' ' || *p == ITEMSEP) @@ -158,7 +158,7 @@ char* trimsep(char *s) { } // originX.asn.cymru.com txtrec: ASN | Route | Country | Registry | Allocated -char* split_txtrec(char *txt_rec) { +static char* split_txtrec(char *txt_rec) { if (!txt_rec) return NULL; if (iihash) { @@ -200,7 +200,7 @@ char* split_txtrec(char *txt_rec) { #ifdef ENABLE_IPV6 // from dns.c:addr2ip6arpa() -void reverse_host6(struct in6_addr *addr, char *buff) { +static void reverse_host6(struct in6_addr *addr, char *buff) { int i; char *b = buff; for (i=(sizeof(*addr)/2-1); i>=0; i--, b+=4) // 64b portion @@ -209,7 +209,7 @@ void reverse_host6(struct in6_addr *addr, char *buff) { } #endif -char *get_ipinfo(ip_t *addr) { +static char *get_ipinfo(ip_t *addr) { if (!addr) return NULL; @@ -263,11 +263,11 @@ char *get_ipinfo(ip_t *addr) { return val; } -int get_iiwidth(void) { +extern int get_iiwidth(void) { return (ipinfo_no < iiwidth_len) ? iiwidth[ipinfo_no] : iiwidth[ipinfo_no % iiwidth_len]; } -char *fmt_ipinfo(ip_t *addr) { +extern char *fmt_ipinfo(ip_t *addr) { char *ipinfo = get_ipinfo(addr); char fmt[8]; snprintf(fmt, sizeof(fmt), "%s%%-%ds", ipinfo_no?"":"AS", get_iiwidth()); @@ -275,11 +275,11 @@ char *fmt_ipinfo(ip_t *addr) { return fmtinfo; } -int is_printii(void) { +extern int is_printii(void) { return ((ipinfo_no >= 0) && (ipinfo_no != ipinfo_max)); } -void asn_open(void) { +extern void asn_open(void) { if (ipinfo_no >= 0) { DEB_syslog(LOG_INFO, "hcreate(%d)", IIHASH_HI); if (!(iihash = hcreate(IIHASH_HI))) @@ -287,7 +287,7 @@ void asn_open(void) { } } -void asn_close(void) { +extern void asn_close(void) { if ((ipinfo_no >= 0) && iihash) { DEB_syslog(LOG_INFO, "hdestroy()"); hdestroy(); diff --git a/asn.h b/asn.h index 4f550a5..b9d0c09 100644 --- a/asn.h +++ b/asn.h @@ -20,8 +20,8 @@ extern int ipinfo_no; extern int ipinfo_max; extern int iiwidth_len; extern int iihash; -void asn_open(); -void asn_close(); -char *fmt_ipinfo(ip_t *addr); -int get_iiwidth(void); -int is_printii(void); +extern void asn_open(); +extern void asn_close(); +extern char *fmt_ipinfo(ip_t *addr); +extern int get_iiwidth(void); +extern int is_printii(void); diff --git a/curses.c b/curses.c index cac0aef..e8856a2 100644 --- a/curses.c +++ b/curses.c @@ -77,7 +77,7 @@ extern int mtrtype; static int __unused_int; -void pwcenter(char *str) +static void pwcenter(char *str) { int maxx; int cx; @@ -90,7 +90,7 @@ void pwcenter(char *str) } -char *format_number (int n, int w, char *buf) +static char *format_number (int n, int w, char *buf) { // XXX todo: implement w != 5.. if (w != 5) return ("unimpl"); @@ -124,8 +124,7 @@ char *format_number (int n, int w, char *buf) } - -int mtr_curses_keyaction(void) +extern int mtr_curses_keyaction(void) { int c = getch(); int i=0; @@ -349,7 +348,7 @@ int mtr_curses_keyaction(void) } -void format_field (char *dst, const char *format, int n) +static void format_field (char *dst, const char *format, int n) { if (index (format, 'N' ) ) { *dst++ = ' '; @@ -364,7 +363,7 @@ void format_field (char *dst, const char *format, int n) } } -void mtr_curses_hosts(int startstat) +static void mtr_curses_hosts(int startstat) { int max; int at; @@ -467,7 +466,7 @@ static double factors[NUM_FACTORS]; static int scale[NUM_FACTORS]; static int low_ms, high_ms; -void mtr_gen_scale(void) +static void mtr_gen_scale(void) { int *saved, i, max, at; int range; @@ -500,7 +499,7 @@ void mtr_gen_scale(void) static char block_map[NUM_FACTORS]; -void mtr_curses_init(void) { +static void mtr_curses_init(void) { int i; int block_split; @@ -536,7 +535,7 @@ static int block_col[NUM_FACTORS+1] = COLOR_PAIR(2)|A_BOLD }; -void mtr_print_scaled(int ms) +static void mtr_print_scaled(int ms) { int i; @@ -552,7 +551,7 @@ void mtr_print_scaled(int ms) } -void mtr_fill_graph(int at, int cols) +static void mtr_fill_graph(int at, int cols) { int* saved; int i; @@ -580,7 +579,7 @@ void mtr_fill_graph(int at, int cols) } -void mtr_curses_graph(int startstat, int cols) +static void mtr_curses_graph(int startstat, int cols) { int max, at, y; ip_t * addr; @@ -620,7 +619,7 @@ void mtr_curses_graph(int startstat, int cols) } -void mtr_curses_redraw(void) +extern void mtr_curses_redraw(void) { int maxx; int startstat; @@ -728,7 +727,7 @@ void mtr_curses_redraw(void) } -void mtr_curses_open(void) +extern void mtr_curses_open(void) { initscr(); raw(); @@ -748,14 +747,14 @@ void mtr_curses_open(void) } -void mtr_curses_close(void) +extern void mtr_curses_close(void) { printw("\n"); endwin(); } -void mtr_curses_clear(void) +extern void mtr_curses_clear(void) { mtr_curses_close(); mtr_curses_open(); diff --git a/display.c b/display.c index 10e1271..3b86e07 100644 --- a/display.c +++ b/display.c @@ -56,7 +56,7 @@ extern int DisplayMode; #define UNUSED_IF_NO_GTK UNUSED #endif -void display_detect(int *argc UNUSED_IF_NO_GTK, char ***argv UNUSED_IF_NO_GTK) +extern void display_detect(int *argc UNUSED_IF_NO_GTK, char ***argv UNUSED_IF_NO_GTK) { DisplayMode = DEFAULT_DISPLAY; @@ -68,7 +68,7 @@ void display_detect(int *argc UNUSED_IF_NO_GTK, char ***argv UNUSED_IF_NO_GTK) } -void display_open(void) +extern void display_open(void) { switch(DisplayMode) { @@ -110,7 +110,7 @@ void display_open(void) } -void display_close(time_t now) +extern void display_close(time_t now) { switch(DisplayMode) { case DisplayReport: @@ -148,7 +148,7 @@ void display_close(time_t now) } -void display_redraw(void) +extern void display_redraw(void) { switch(DisplayMode) { @@ -171,7 +171,7 @@ void display_redraw(void) } -int display_keyaction(void) +extern int display_keyaction(void) { switch(DisplayMode) { #ifdef HAVE_NCURSES @@ -191,7 +191,7 @@ int display_keyaction(void) } -void display_rawxmit(int host, int seq) +extern void display_rawxmit(int host, int seq) { switch(DisplayMode) { case DisplayRaw: @@ -201,7 +201,7 @@ void display_rawxmit(int host, int seq) } -void display_rawping(int host, int msec, int seq) +extern void display_rawping(int host, int msec, int seq) { switch(DisplayMode) { case DisplayReport: @@ -224,7 +224,7 @@ void display_rawping(int host, int msec, int seq) } -void display_rawhost(int host, ip_t *ip_addr) +extern void display_rawhost(int host, ip_t *ip_addr) { switch(DisplayMode) { case DisplayReport: @@ -247,7 +247,7 @@ void display_rawhost(int host, ip_t *ip_addr) } -void display_loop(void) +extern void display_loop(void) { switch(DisplayMode) { case DisplayReport: @@ -271,7 +271,7 @@ void display_loop(void) } -void display_clear(void) +extern void display_clear(void) { switch(DisplayMode) { #ifdef HAVE_NCURSES diff --git a/display.h b/display.h index 267eca9..26ef3a3 100644 --- a/display.h +++ b/display.h @@ -50,16 +50,16 @@ enum { }; /* Prototypes for display.c */ -void display_detect(int *argc, char ***argv); -void display_open(void); -void display_close(time_t now); -void display_redraw(void); -void display_rawxmit(int hostnum, int seq); -void display_rawping(int hostnum, int msec, int seq); -void display_rawhost(int hostnum, ip_t *ip_addr); -int display_keyaction(void); -void display_loop(void); -void display_clear(void); +extern void display_detect(int *argc, char ***argv); +extern void display_open(void); +extern void display_close(time_t now); +extern void display_redraw(void); +extern void display_rawxmit(int hostnum, int seq); +extern void display_rawping(int hostnum, int msec, int seq); +extern void display_rawhost(int hostnum, ip_t *ip_addr); +extern int display_keyaction(void); +extern void display_loop(void); +extern void display_clear(void); extern int display_mode; extern int display_offset; /* only used in text mode */ diff --git a/dns.c b/dns.c index a7ab5d6..0e69eb4 100644 --- a/dns.c +++ b/dns.c @@ -76,7 +76,7 @@ struct dns_results { struct dns_results *results; -char *strlongip(ip_t * ip) +extern char *strlongip(ip_t * ip) { #ifdef ENABLE_IPV6 static char addrstr[INET6_ADDRSTRLEN]; @@ -94,7 +94,7 @@ char *strlongip(ip_t * ip) #define UNUSED_IF_NO_IPV6 UNUSED #endif -int longipstr( char *s, ip_t *dst, int family UNUSED_IF_NO_IPV6) +static int longipstr( char *s, ip_t *dst, int family UNUSED_IF_NO_IPV6) { #ifdef ENABLE_IPV6 return inet_pton( family, s, dst ); @@ -104,7 +104,7 @@ int longipstr( char *s, ip_t *dst, int family UNUSED_IF_NO_IPV6) } -struct hostent * dns_forward(const char *name) +extern struct hostent * dns_forward(const char *name) { struct hostent *host; @@ -115,7 +115,7 @@ struct hostent * dns_forward(const char *name) } -struct dns_results *findip (ip_t *ip) +static struct dns_results *findip (ip_t *ip) { struct dns_results *t; @@ -129,7 +129,7 @@ struct dns_results *findip (ip_t *ip) return NULL; } -void set_sockaddr_ip (struct sockaddr_storage *sa, ip_t *ip) +static void set_sockaddr_ip (struct sockaddr_storage *sa, ip_t *ip) { struct sockaddr_in *sa_in; struct sockaddr_in6 *sa_in6; @@ -154,12 +154,12 @@ static int todns[2], fromdns[2]; FILE *fromdnsfp; #if 0 -void handle_sigchld(int sig) { +static void handle_sigchld(int sig) { while (waitpid((pid_t)(-1), 0, WNOHANG) > 0) {} } #endif -void dns_open(void) +extern void dns_open(void) { int pid; @@ -247,14 +247,13 @@ void dns_open(void) } } -int dns_waitfd (void) +extern int dns_waitfd (void) { return fromdns[0]; } - -void dns_ack(void) +extern void dns_ack(void) { char buf[2048], host[NI_MAXHOST], name[NI_MAXHOST]; ip_t hostip; @@ -276,12 +275,12 @@ void dns_ack(void) #ifdef ENABLE_IPV6 -int dns_waitfd6 (void) +extern int dns_waitfd6 (void) { return -1; } -void dns_ack6(void) +extern void dns_ack6(void) { return; } @@ -289,7 +288,7 @@ void dns_ack6(void) #endif -char *dns_lookup2(ip_t * ip) +extern char *dns_lookup2(ip_t * ip) { struct dns_results *r; char buf[INET6_ADDRSTRLEN + 1]; @@ -321,7 +320,7 @@ char *dns_lookup2(ip_t * ip) } -char *dns_lookup(ip_t * ip) +extern char *dns_lookup(ip_t * ip) { char *t; @@ -332,7 +331,7 @@ char *dns_lookup(ip_t * ip) #if 0 -char *strlongip(ip_t * ip) +extern char *strlongip(ip_t * ip) { #ifdef ENABLE_IPV6 static char addrstr[INET6_ADDRSTRLEN]; @@ -348,7 +347,7 @@ char *strlongip(ip_t * ip) // XXX check if necessary/exported. /* Resolve an IP address to a hostname. */ -struct hostent *addr2host( const char *addr, int family ) { +extern struct hostent *addr2host( const char *addr, int family ) { int len = 0; switch ( family ) { case AF_INET: diff --git a/dns.h b/dns.h index 5b3b5fb..da933c5 100644 --- a/dns.h +++ b/dns.h @@ -22,12 +22,12 @@ /* Prototypes for dns.c */ -void dns_open(void); -int dns_waitfd(void); -void dns_ack(void); +extern void dns_open(void); +extern int dns_waitfd(void); +extern void dns_ack(void); #ifdef ENABLE_IPV6 -int dns_waitfd6(void); -void dns_ack6(void); +extern int dns_waitfd6(void); +extern void dns_ack6(void); #ifdef NEED_RES_STATE_EXT /* __res_state_ext is missing on many (most?) BSD systems */ struct __res_state_ext { @@ -45,10 +45,10 @@ struct __res_state_ext { #endif #endif -char *dns_lookup(ip_t * address); -char *dns_lookup2(ip_t * address); -struct hostent * dns_forward(const char *name); -char *strlongip(ip_t * ip); +extern char *dns_lookup(ip_t * address); +extern char *dns_lookup2(ip_t * address); +extern struct hostent * dns_forward(const char *name); +extern char *strlongip(ip_t * ip); -void addr2ip6arpa( ip_t * ip, char * buf ); -struct hostent *addr2host( const char *addr, int type ); +extern void addr2ip6arpa( ip_t * ip, char * buf ); +extern struct hostent *addr2host( const char *addr, int type ); diff --git a/gtk.c b/gtk.c index 8d4cedb..2a3d878 100644 --- a/gtk.c +++ b/gtk.c @@ -39,11 +39,11 @@ #include "img/mtr_icon.xpm" #endif -gint gtk_ping(gpointer data); -gint Copy_activate(GtkWidget *widget, gpointer data); -gint NewDestination_activate(GtkWidget *widget, gpointer data); -gboolean ReportTreeView_clicked(GtkWidget *Tree, GdkEventButton *event); -gchar* getSelectedHost(GtkTreePath *path); +static gint gtk_ping(gpointer data); +static gint Copy_activate(GtkWidget *widget, gpointer data); +static gint NewDestination_activate(GtkWidget *widget, gpointer data); +static gboolean ReportTreeView_clicked(GtkWidget *Tree, GdkEventButton *event); +static gchar* getSelectedHost(GtkTreePath *path); @@ -55,7 +55,7 @@ static GtkWidget *Pause_Button; static GtkWidget *Entry; static GtkWidget *main_window; -void gtk_add_ping_timeout (void) +static void gtk_add_ping_timeout (void) { if(gtk_toggle_button_get_active((GtkToggleButton *)Pause_Button)){ return; @@ -66,7 +66,7 @@ void gtk_add_ping_timeout (void) } -void gtk_do_init(int *argc, char ***argv) +static void gtk_do_init(int *argc, char ***argv) { static int done = 0; @@ -78,7 +78,7 @@ void gtk_do_init(int *argc, char ***argv) } -int gtk_detect(UNUSED int *argc, UNUSED char ***argv) +extern int gtk_detect(UNUSED int *argc, UNUSED char ***argv) { if(getenv("DISPLAY") != NULL) { /* If we do this here, gtk_init exits on an error. This happens @@ -91,7 +91,7 @@ int gtk_detect(UNUSED int *argc, UNUSED char ***argv) } -gint Window_destroy(UNUSED GtkWidget *Window, UNUSED gpointer data) +static gint Window_destroy(UNUSED GtkWidget *Window, UNUSED gpointer data) { gtk_main_quit(); @@ -99,7 +99,7 @@ gint Window_destroy(UNUSED GtkWidget *Window, UNUSED gpointer data) } -gint Restart_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data) +static gint Restart_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data) { net_reset(); gtk_redraw(); @@ -108,7 +108,7 @@ gint Restart_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data) } -gint Pause_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data) +static gint Pause_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data) { static int paused = 0; @@ -123,7 +123,7 @@ gint Pause_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data) return FALSE; } -gint About_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data) +static gint About_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data) { gchar *authors[] = { "Matt Kimball ", @@ -198,7 +198,7 @@ gint About_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data) * What's the problem with this? (-> "I don't think so) */ -gint WaitTime_changed(UNUSED GtkAdjustment *Adj, UNUSED GtkWidget *Button) +static gint WaitTime_changed(UNUSED GtkAdjustment *Adj, UNUSED GtkWidget *Button) { WaitTime = gtk_spin_button_get_value(GTK_SPIN_BUTTON(Button)); g_source_remove (ping_timeout_timer); @@ -209,7 +209,7 @@ gint WaitTime_changed(UNUSED GtkAdjustment *Adj, UNUSED GtkWidget *Button) } -gint Host_activate(GtkWidget *entry, UNUSED gpointer data) +static gint Host_activate(GtkWidget *entry, UNUSED gpointer data) { struct hostent * addr; @@ -230,7 +230,7 @@ gint Host_activate(GtkWidget *entry, UNUSED gpointer data) -void Toolbar_fill(GtkWidget *Toolbar) +static void Toolbar_fill(GtkWidget *Toolbar) { GtkWidget *Button; GtkWidget *Label; @@ -311,7 +311,7 @@ enum { // earlier, so it is ok. Nothing to worry about.... #define POINTER_TO_INT(p) ((int)(long)(p)) -void float_formatter(GtkTreeViewColumn *tree_column UNUSED, +static void float_formatter(GtkTreeViewColumn *tree_column UNUSED, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, @@ -324,7 +324,7 @@ void float_formatter(GtkTreeViewColumn *tree_column UNUSED, g_object_set(cell, "text", text, NULL); } -void percent_formatter(GtkTreeViewColumn *tree_column UNUSED, +static void percent_formatter(GtkTreeViewColumn *tree_column UNUSED, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, @@ -337,7 +337,7 @@ void percent_formatter(GtkTreeViewColumn *tree_column UNUSED, g_object_set(cell, "text", text, NULL); } -void TreeViewCreate(void) +static void TreeViewCreate(void) { GtkCellRenderer *renderer; GtkTreeViewColumn *column; @@ -460,7 +460,7 @@ void TreeViewCreate(void) } -void update_tree_row(int row, GtkTreeIter *iter) +static void update_tree_row(int row, GtkTreeIter *iter) { ip_t *addr; char str[256]="???", *name=str; @@ -497,7 +497,7 @@ void update_tree_row(int row, GtkTreeIter *iter) #endif } -void gtk_redraw(void) +extern void gtk_redraw(void) { int max = net_max(); @@ -522,7 +522,7 @@ void gtk_redraw(void) } -void Window_fill(GtkWidget *Window) +static void Window_fill(GtkWidget *Window) { GtkWidget *VBox; GtkWidget *Toolbar; @@ -548,7 +548,7 @@ void Window_fill(GtkWidget *Window) } -void gtk_open(void) +extern void gtk_open(void) { GdkPixbuf *icon; @@ -579,18 +579,18 @@ void gtk_open(void) } -void gtk_close(void) +extern void gtk_close(void) { } -int gtk_keyaction(void) +extern int gtk_keyaction(void) { return 0; } -gint gtk_ping(UNUSED gpointer data) +static gint gtk_ping(UNUSED gpointer data) { gtk_redraw(); net_send_batch(); @@ -601,21 +601,21 @@ gint gtk_ping(UNUSED gpointer data) } -gboolean gtk_net_data(UNUSED GIOChannel *channel, UNUSED GIOCondition cond, UNUSED gpointer data) +static gboolean gtk_net_data(UNUSED GIOChannel *channel, UNUSED GIOCondition cond, UNUSED gpointer data) { net_process_return(); return TRUE; } -gboolean gtk_dns_data(UNUSED GIOChannel *channel, UNUSED GIOCondition cond, UNUSED gpointer data) +static gboolean gtk_dns_data(UNUSED GIOChannel *channel, UNUSED GIOCondition cond, UNUSED gpointer data) { dns_ack(); gtk_redraw(); return TRUE; } #ifdef ENABLE_IPV6 -gboolean gtk_dns_data6(UNUSED GIOChannel *channel, UNUSED GIOCondition cond, UNUSED gpointer data) +static gboolean gtk_dns_data6(UNUSED GIOChannel *channel, UNUSED GIOCondition cond, UNUSED gpointer data) { dns_ack6(); gtk_redraw(); @@ -624,7 +624,7 @@ gboolean gtk_dns_data6(UNUSED GIOChannel *channel, UNUSED GIOCondition cond, UNU #endif -void gtk_loop(void) +extern void gtk_loop(void) { GIOChannel *net_iochannel, *dns_iochannel; @@ -644,7 +644,7 @@ void gtk_loop(void) gtk_main(); } -gboolean NewDestination_activate(GtkWidget *widget UNUSED, gpointer data) +static gboolean NewDestination_activate(GtkWidget *widget UNUSED, gpointer data) { gchar *hostname; GtkTreePath *path = (GtkTreePath*)data; @@ -659,7 +659,7 @@ gboolean NewDestination_activate(GtkWidget *widget UNUSED, gpointer data) } -gboolean Copy_activate(GtkWidget *widget UNUSED, gpointer data) +static gboolean Copy_activate(GtkWidget *widget UNUSED, gpointer data) { gchar *hostname; GtkTreePath *path = (GtkTreePath*)data; @@ -680,7 +680,7 @@ gboolean Copy_activate(GtkWidget *widget UNUSED, gpointer data) return TRUE; } -gchar *getSelectedHost(GtkTreePath *path) +static gchar *getSelectedHost(GtkTreePath *path) { GtkTreeIter iter; gchar *name = NULL; @@ -693,7 +693,7 @@ gchar *getSelectedHost(GtkTreePath *path) } -gboolean ReportTreeView_clicked(GtkWidget *Tree UNUSED, GdkEventButton *event) +static gboolean ReportTreeView_clicked(GtkWidget *Tree UNUSED, GdkEventButton *event) { GtkWidget* popup_menu; GtkWidget* copy_item; diff --git a/mtr-curses.h b/mtr-curses.h index e5099fb..20408ff 100644 --- a/mtr-curses.h +++ b/mtr-curses.h @@ -17,8 +17,8 @@ */ /* Prototypes for curses.c */ -void mtr_curses_open(void); -void mtr_curses_close(void); -void mtr_curses_redraw(void); -int mtr_curses_keyaction(void); -void mtr_curses_clear(void); +extern void mtr_curses_open(void); +extern void mtr_curses_close(void); +extern void mtr_curses_redraw(void); +extern int mtr_curses_keyaction(void); +extern void mtr_curses_clear(void); diff --git a/mtr-gtk.h b/mtr-gtk.h index cb27186..9286e90 100644 --- a/mtr-gtk.h +++ b/mtr-gtk.h @@ -17,9 +17,9 @@ */ /* Prototypes for gtk.c */ -int gtk_detect(int *argc, char ***argv); -void gtk_open(void); -void gtk_close(void); -void gtk_redraw(void); -int gtk_keyaction(void); -void gtk_loop(void); +extern int gtk_detect(int *argc, char ***argv); +extern void gtk_open(void); +extern void gtk_close(void); +extern void gtk_redraw(void); +extern int gtk_keyaction(void); +extern void gtk_loop(void); diff --git a/mtr.c b/mtr.c index c471904..d6e96c7 100644 --- a/mtr.c +++ b/mtr.c @@ -218,7 +218,7 @@ strtofloat_or_err (const char *str, const char *errmesg) } -char * +extern char * trim(char * s) { char * p = s; @@ -327,7 +327,7 @@ unlock(FILE *f) { } -void init_fld_options (void) +static void init_fld_options (void) { int i; @@ -342,7 +342,7 @@ void init_fld_options (void) } -void parse_arg (int argc, char **argv) +static void parse_arg (int argc, char **argv) { int opt; int i; @@ -667,7 +667,7 @@ void parse_arg (int argc, char **argv) } -void parse_mtr_options (char *string) +static void parse_mtr_options (char *string) { int argc; char *argv[128], *p; @@ -690,7 +690,7 @@ void parse_mtr_options (char *string) } -int main(int argc, char **argv) +extern int main(int argc, char **argv) { struct hostent * host = NULL; int net_preopen_result; diff --git a/mtr.h b/mtr.h index 047d31d..0c4c821 100644 --- a/mtr.h +++ b/mtr.h @@ -73,5 +73,5 @@ extern int use_dns; typedef int socklen_t; #endif -char * +extern char * trim(char * s); diff --git a/net.c b/net.c index fd96b96..32dcfac 100644 --- a/net.c +++ b/net.c @@ -46,6 +46,9 @@ #include "display.h" #include "dns.h" +static void sockaddrtop( struct sockaddr * saddr, char * strptr, size_t len ); +static void decodempls(int, char *, struct mplslen *, int); + /* We can't rely on header files to provide this information, because the fields have different names between, for instance, Linux and Solaris */ @@ -234,7 +237,7 @@ int calc_deltatime (float waittime) } -int checksum(void *data, int sz) +static int checksum(void *data, int sz) { uint16 *ch; uint32 sum; @@ -259,7 +262,7 @@ int checksum(void *data, int sz) /* Prepend pseudoheader to the udp datagram and calculate checksum */ -int udp_checksum(void *pheader, void *udata, int psize, int dsize, int alt_checksum) +static int udp_checksum(void *pheader, void *udata, int psize, int dsize, int alt_checksum) { unsigned int tsize = psize + dsize; char csumpacket[tsize]; @@ -288,7 +291,7 @@ int udp_checksum(void *pheader, void *udata, int psize, int dsize, int alt_check } -void save_sequence(int index, int seq) +static void save_sequence(int index, int seq) { display_rawxmit(index, seq); @@ -304,7 +307,7 @@ void save_sequence(int index, int seq) net_save_xmit(index); } -int new_sequence(int index) +static int new_sequence(int index) { static int next_sequence = MinSequence; int seq; @@ -319,7 +322,7 @@ int new_sequence(int index) } /* Attempt to connect to a TCP port with a TTL */ -void net_send_tcp(int index) +static void net_send_tcp(int index) { int ttl, s; int port; @@ -438,7 +441,7 @@ void net_send_tcp(int index) #ifdef HAS_SCTP /* Attempt to connect to a SCTP port with a TTL */ -void net_send_sctp(int index) +static void net_send_sctp(int index) { int ttl, s; int opt = 1; @@ -549,7 +552,7 @@ void net_send_sctp(int index) #endif /* Attempt to find the host at a particular number of hops away */ -void net_send_query(int index) +static void net_send_query(int index) { if (mtrtype == IPPROTO_TCP) { net_send_tcp(index); @@ -744,7 +747,7 @@ void net_send_query(int index) /* We got a return on something we sent out. Record the address and time. */ -void net_process_ping(int seq, struct mplslen mpls, void * addr, struct timeval now) +static void net_process_ping(int seq, struct mplslen mpls, void * addr, struct timeval now) { int index; int totusec; @@ -857,7 +860,7 @@ void net_process_ping(int seq, struct mplslen mpls, void * addr, struct timeval /* We know a packet has come in, because the main select loop has called us, now we just need to read it, see if it is for us, and if it is a reply to something we sent, then call net_process_ping() */ -void net_process_return(void) +extern void net_process_return(void) { char packet[MAXPACKET]; #ifdef ENABLE_IPV6 @@ -1099,28 +1102,28 @@ void net_process_return(void) } -ip_t *net_addr(int at) +extern ip_t *net_addr(int at) { return (ip_t *)&(host[at].addr); } -ip_t *net_addrs(int at, int i) +extern ip_t *net_addrs(int at, int i) { return (ip_t *)&(host[at].addrs[i]); } -void *net_mpls(int at) +extern void *net_mpls(int at) { return (struct mplslen *)&(host[at].mplss); } -void *net_mplss(int at, int i) +extern void *net_mplss(int at, int i) { return (struct mplslen *)&(host[at].mplss[i]); } -int net_loss(int at) +extern int net_loss(int at) { if ((host[at].xmit - host[at].transit) == 0) return 0; @@ -1129,43 +1132,43 @@ int net_loss(int at) } -int net_drop(int at) +extern int net_drop(int at) { return (host[at].xmit - host[at].transit) - host[at].returned; } -int net_last(int at) +extern int net_last(int at) { return (host[at].last); } -int net_best(int at) +extern int net_best(int at) { return (host[at].best); } -int net_worst(int at) +extern int net_worst(int at) { return (host[at].worst); } -int net_avg(int at) +extern int net_avg(int at) { return (host[at].avg); } -int net_gmean(int at) +extern int net_gmean(int at) { return (host[at].gmean); } -int net_stdev(int at) +extern int net_stdev(int at) { if( host[at].returned > 1 ) { return ( sqrt( host[at].ssd/(host[at].returned -1.0) ) ); @@ -1175,31 +1178,31 @@ int net_stdev(int at) } -int net_jitter(int at) +extern int net_jitter(int at) { return (host[at].jitter); } -int net_jworst(int at) +extern int net_jworst(int at) { return (host[at].jworst); } -int net_javg(int at) +extern int net_javg(int at) { return (host[at].javg); } -int net_jinta(int at) +extern int net_jinta(int at) { return (host[at].jinta); } -int net_max(void) +extern int net_max(void) { int at; int max; @@ -1220,37 +1223,37 @@ int net_max(void) } -int net_min (void) +extern int net_min (void) { return ( fstTTL - 1 ); } -int net_returned(int at) +extern int net_returned(int at) { return host[at].returned; } -int net_xmit(int at) +extern int net_xmit(int at) { return host[at].xmit; } -int net_up(int at) +extern int net_up(int at) { return host[at].up; } -char * net_localaddr (void) +extern char * net_localaddr (void) { return localaddr; } -void net_end_transit(void) +extern void net_end_transit(void) { int at; @@ -1259,7 +1262,7 @@ void net_end_transit(void) } } -int net_send_batch(void) +extern int net_send_batch(void) { int n_unknown=0, i; @@ -1339,7 +1342,7 @@ static void set_fd_flags(int fd) #endif } -int net_preopen(void) +extern int net_preopen(void) { int trueopt = 1; @@ -1379,7 +1382,7 @@ int net_preopen(void) } -int net_selectsocket(void) +extern int net_selectsocket(void) { #if !defined(IP_HDRINCL) && defined(IP_TOS) && defined(IP_TTL) switch ( mtrtype ) { @@ -1410,7 +1413,7 @@ int net_selectsocket(void) } -int net_open(struct hostent * hostent) +extern int net_open(struct hostent * hostent) { #ifdef ENABLE_IPV6 struct sockaddr_storage name_struct; @@ -1459,7 +1462,7 @@ int net_open(struct hostent * hostent) } -void net_reopen(struct hostent * addr) +extern void net_reopen(struct hostent * addr) { int at; @@ -1488,7 +1491,7 @@ void net_reopen(struct hostent * addr) } -void net_reset(void) +extern void net_reset(void) { int at; int i; @@ -1529,7 +1532,7 @@ void net_reset(void) gettimeofday(&reset, NULL); } -int net_set_interfaceaddress_udp(void) +static int net_set_interfaceaddress_udp(void) { struct sockaddr_in * sa4; struct sockaddr_storage remote; @@ -1592,7 +1595,7 @@ int net_set_interfaceaddress_udp(void) } -int net_set_interfaceaddress (char *InterfaceAddress) +extern int net_set_interfaceaddress (char *InterfaceAddress) { #ifdef ENABLE_IPV6 struct sockaddr_storage name_struct; @@ -1640,7 +1643,7 @@ int net_set_interfaceaddress (char *InterfaceAddress) -void net_close(void) +extern void net_close(void) { if (sendsock4 >= 0) { close(sendsock4_icmp); @@ -1655,19 +1658,19 @@ void net_close(void) } -int net_waitfd(void) +extern int net_waitfd(void) { return recvsock; } -int* net_saved_pings(int at) +extern int* net_saved_pings(int at) { return host[at].saved; } -void net_save_increment(void) +static void net_save_increment(void) { int at; for (at = 0; at < MaxHost; at++) { @@ -1678,7 +1681,7 @@ void net_save_increment(void) } -void net_save_xmit(int at) +extern void net_save_xmit(int at) { if (host[at].saved[SAVED_PINGS-1] != -2) net_save_increment(); @@ -1686,7 +1689,7 @@ void net_save_xmit(int at) } -void net_save_return(int at, int seq, int ms) +extern void net_save_return(int at, int seq, int ms) { int idx; idx = seq - host[at].saved_seq_offset; @@ -1697,7 +1700,7 @@ void net_save_return(int at, int seq, int ms) } /* Similar to inet_ntop but uses a sockaddr as it's argument. */ -void sockaddrtop( struct sockaddr * saddr, char * strptr, size_t len ) { +static void sockaddrtop( struct sockaddr * saddr, char * strptr, size_t len ) { struct sockaddr_in * sa4; #ifdef ENABLE_IPV6 struct sockaddr_in6 * sa6; @@ -1724,7 +1727,7 @@ void sockaddrtop( struct sockaddr * saddr, char * strptr, size_t len ) { } /* Address comparison. */ -int addrcmp( char * a, char * b, int family ) { +extern int addrcmp( char * a, char * b, int family ) { int rc = -1; switch ( family ) { @@ -1742,7 +1745,7 @@ int addrcmp( char * a, char * b, int family ) { } /* Address copy. */ -void addrcpy( char * a, char * b, int family ) { +extern void addrcpy( char * a, char * b, int family ) { switch ( family ) { case AF_INET: @@ -1757,7 +1760,7 @@ void addrcpy( char * a, char * b, int family ) { } /* Decode MPLS */ -void decodempls(int num, char *packet, struct mplslen *mpls, int offset) { +static void decodempls(int num, char *packet, struct mplslen *mpls, int offset) { int i; unsigned int ext_ver, ext_res, ext_chk, obj_hdr_len; @@ -1796,7 +1799,7 @@ void decodempls(int num, char *packet, struct mplslen *mpls, int offset) { } /* Add open sockets to select() */ -void net_add_fds(fd_set *writefd, int *maxfd) +extern void net_add_fds(fd_set *writefd, int *maxfd) { int at, fd; for (at = 0; at < MaxSequence; at++) { @@ -1810,7 +1813,7 @@ void net_add_fds(fd_set *writefd, int *maxfd) } /* check if we got connection or error on any fds */ -void net_process_fds(fd_set *writefd) +extern void net_process_fds(fd_set *writefd) { int at, fd, r; struct timeval now; @@ -1847,7 +1850,7 @@ void net_process_fds(fd_set *writefd) } /* for GTK frontend */ -void net_harvest_fds(void) +extern void net_harvest_fds(void) { fd_set writefd; int maxfd = 0; diff --git a/net.h b/net.h index e8daa9d..ad11ac8 100644 --- a/net.h +++ b/net.h @@ -26,60 +26,58 @@ #include #endif -int net_preopen(void); -int net_selectsocket(void); -int net_open(struct hostent *host); -void net_reopen(struct hostent *address); -int net_set_interfaceaddress (char *InterfaceAddress); -void net_reset(void); -void net_close(void); -int net_waitfd(void); -void net_process_return(void); -void net_harvest_fds(void); - -int net_max(void); -int net_min(void); -int net_last(int at); -ip_t * net_addr(int at); -void * net_mpls(int at); -void * net_mplss(int, int); -int net_loss(int at); -int net_drop(int at); -int net_last(int at); -int net_best(int at); -int net_worst(int at); -int net_avg(int at); -int net_gmean(int at); -int net_stdev(int at); -int net_jitter(int at); -int net_jworst(int at); -int net_javg(int at); -int net_jinta(int at); -ip_t * net_addrs(int at, int i); -char *net_localaddr(void); - -int net_send_batch(void); -void net_end_transit(void); - -int calc_deltatime (float WaitTime); - -int net_returned(int at); -int net_xmit(int at); - -int net_up(int at); +extern int net_preopen(void); +extern int net_selectsocket(void); +extern int net_open(struct hostent *host); +extern void net_reopen(struct hostent *address); +extern int net_set_interfaceaddress (char *InterfaceAddress); +extern void net_reset(void); +extern void net_close(void); +extern int net_waitfd(void); +extern void net_process_return(void); +extern void net_harvest_fds(void); + +extern int net_max(void); +extern int net_min(void); +extern int net_last(int at); +extern ip_t * net_addr(int at); +extern void * net_mpls(int at); +extern void * net_mplss(int, int); +extern int net_loss(int at); +extern int net_drop(int at); +extern int net_last(int at); +extern int net_best(int at); +extern int net_worst(int at); +extern int net_avg(int at); +extern int net_gmean(int at); +extern int net_stdev(int at); +extern int net_jitter(int at); +extern int net_jworst(int at); +extern int net_javg(int at); +extern int net_jinta(int at); +extern ip_t * net_addrs(int at, int i); +extern char *net_localaddr(void); + +extern int net_send_batch(void); +extern void net_end_transit(void); + +extern int calc_deltatime (float WaitTime); + +extern int net_returned(int at); +extern int net_xmit(int at); + +extern int net_up(int at); #define SAVED_PINGS 200 -int* net_saved_pings(int at); -void net_save_xmit(int at); -void net_save_return(int at, int seq, int ms); -int net_duplicate(int at, int seq); +extern int* net_saved_pings(int at); +extern void net_save_xmit(int at); +extern void net_save_return(int at, int seq, int ms); -void sockaddrtop( struct sockaddr * saddr, char * strptr, size_t len ); -int addrcmp( char * a, char * b, int af ); -void addrcpy( char * a, char * b, int af ); +extern int addrcmp( char * a, char * b, int af ); +extern void addrcpy( char * a, char * b, int af ); -void net_add_fds(fd_set *writefd, int *maxfd); -void net_process_fds(fd_set *writefd); +extern void net_add_fds(fd_set *writefd, int *maxfd); +extern void net_process_fds(fd_set *writefd); #define MAXPATH 8 #define MaxHost 256 @@ -134,8 +132,6 @@ struct mplslen { char labels; /* how many labels did we get? */ }; -void decodempls(int, char *, struct mplslen *, int); - #ifdef IPPROTO_SCTP #define HAS_SCTP #endif diff --git a/raw.c b/raw.c index f8e8876..ed190de 100644 --- a/raw.c +++ b/raw.c @@ -48,14 +48,14 @@ static char *addr_to_str(ip_t addr) #endif // Log an echo request, or a "ping" -void raw_rawxmit (int host, int seq) +extern void raw_rawxmit (int host, int seq) { printf ("x %d %d\n", host, seq); fflush (stdout); } // Log an echo reply, or a "pong" -void raw_rawping (int host, int msec, int seq) +extern void raw_rawping (int host, int msec, int seq) { char *name; @@ -71,7 +71,7 @@ void raw_rawping (int host, int msec, int seq) } -void raw_rawhost (int host, ip_t * ip_addr) +extern void raw_rawhost (int host, ip_t * ip_addr) { printf ("h %d %s\n", host, strlongip( ip_addr )); fflush (stdout); diff --git a/raw.h b/raw.h index 3679f58..8f204a5 100644 --- a/raw.h +++ b/raw.h @@ -19,6 +19,6 @@ */ /* Prototypes for raw.c */ -void raw_rawxmit(int host, int seq); -void raw_rawping(int host, int msec, int seq); -void raw_rawhost(int host, ip_t * addr); +extern void raw_rawxmit(int host, int seq); +extern void raw_rawping(int host, int msec, int seq); +extern void raw_rawhost(int host, ip_t * addr); diff --git a/report.c b/report.c index 83f3156..7ee7521 100644 --- a/report.c +++ b/report.c @@ -48,7 +48,7 @@ extern int af; extern int reportwide; -void report_open(void) +extern void report_open(void) { const time_t now = time(NULL); char *t = ctime (&now); @@ -72,14 +72,14 @@ static size_t snprint_addr(char *dst, size_t dst_len, ip_t *addr) #ifdef HAVE_IPINFO -void print_mpls(struct mplslen *mpls) { +static void print_mpls(struct mplslen *mpls) { int k; for (k=0; k < mpls->labels; k++) printf(" [MPLS: Lbl %lu Exp %u S %cu TTL %u]\n", mpls->label[k], mpls->exp[k], mpls->s[k], mpls->ttl[k]); } #endif -void report_close(void) +extern void report_close(void) { int i, j, at, max, z, w; struct mplslen *mpls, *mplss; @@ -242,23 +242,23 @@ void report_close(void) } -void txt_open(void) +extern void txt_open(void) { } -void txt_close(void) +extern void txt_close(void) { report_close(); } -void json_open(void) +extern void json_open(void) { } -void json_close(void) +extern void json_close(void) { int i, j, at, first, max; ip_t *addr; @@ -347,12 +347,12 @@ void json_close(void) -void xml_open(void) +extern void xml_open(void) { } -void xml_close(void) +extern void xml_close(void) { int i, j, at, max; ip_t *addr; @@ -414,11 +414,11 @@ void xml_close(void) } -void csv_open(void) +extern void csv_open(void) { } -void csv_close(time_t now) +extern void csv_close(time_t now) { int i, j, at, max; ip_t *addr; diff --git a/report.h b/report.h index 566be3e..8dbee91 100644 --- a/report.h +++ b/report.h @@ -18,13 +18,13 @@ /* Prototypes for report.h */ -void report_open(void); -void report_close(void); -void txt_open(void); -void txt_close(void); -void json_open(void); -void json_close(void); -void xml_open(void); -void xml_close(void); -void csv_open(void); -void csv_close(time_t now); +extern void report_open(void); +extern void report_close(void); +extern void txt_open(void); +extern void txt_close(void); +extern void json_open(void); +extern void json_close(void); +extern void xml_open(void); +extern void xml_close(void); +extern void csv_open(void); +extern void csv_close(time_t now); diff --git a/select.c b/select.c index 52d81e1..01e4b58 100644 --- a/select.c +++ b/select.c @@ -49,7 +49,7 @@ int display_offset = 0; #define GRACETIME (GraceTime * 1000*1000) -void select_loop(void) { +extern void select_loop(void) { fd_set readfd; fd_set writefd; int anyset = 0; diff --git a/select.h b/select.h index 68903e3..ffa6ded 100644 --- a/select.h +++ b/select.h @@ -16,4 +16,4 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -void select_loop(void); +extern void select_loop(void); diff --git a/split.c b/split.c index 937ab9d..9cbb5e5 100644 --- a/split.c +++ b/split.c @@ -67,7 +67,7 @@ int LineCount; #define DEBUG 0 -void split_redraw(void) +extern void split_redraw(void) { int max; int at; @@ -129,7 +129,7 @@ void split_redraw(void) } -void split_open(void) +extern void split_open(void) { int i; #if DEBUG @@ -142,7 +142,7 @@ void split_open(void) } -void split_close(void) +extern void split_close(void) { #if DEBUG printf("split_close()\n"); @@ -150,7 +150,7 @@ void split_close(void) } -int split_keyaction(void) +extern int split_keyaction(void) { #ifdef HAVE_NCURSES char c = getch(); diff --git a/split.h b/split.h index a9b9405..b57e546 100644 --- a/split.h +++ b/split.h @@ -19,7 +19,7 @@ */ /* Prototypes for split.c */ -void split_open(void); -void split_close(void); -void split_redraw(void); -int split_keyaction(void); +extern void split_open(void); +extern void split_close(void); +extern void split_redraw(void); +extern int split_keyaction(void); -- 2.47.2