From 63cc23401aa06cdd9e6501633e53371a80810541 Mon Sep 17 00:00:00 2001 From: jfreegman Date: Mon, 8 Oct 2018 13:39:04 -0400 Subject: [PATCH] Improve readability of defines --- src/api.h | 2 +- src/audio_call.c | 6 +++--- src/audio_device.c | 4 ++-- src/autocomplete.c | 2 +- src/autocomplete.h | 2 +- src/bootstrap.h | 2 +- src/chat.c | 10 +++++----- src/chat_commands.h | 2 +- src/configdir.h | 2 +- src/curl_util.h | 2 +- src/execute.h | 2 +- src/file_transfers.h | 2 +- src/global_commands.h | 4 ++-- src/group_commands.h | 2 +- src/groupchat.c | 6 +++--- src/groupchat.h | 2 +- src/help.c | 4 ++-- src/help.h | 2 +- src/input.h | 2 +- src/line_info.h | 2 +- src/log.h | 2 +- src/message_queue.h | 2 +- src/misc_tools.h | 2 +- src/notify.c | 46 +++++++++++++++++++------------------------ src/python_api.h | 2 +- src/settings.h | 3 ++- src/term_mplex.h | 6 +++--- src/toxic.c | 4 ++-- src/toxic.h | 2 +- src/toxic_strings.h | 2 +- src/video_call.c | 2 +- src/video_device.c | 4 ++-- src/windows.c | 2 +- src/windows.h | 2 +- 34 files changed, 69 insertions(+), 74 deletions(-) diff --git a/src/api.h b/src/api.h index 5875d01..74d7942 100644 --- a/src/api.h +++ b/src/api.h @@ -39,4 +39,4 @@ int help_max_width(void); void draw_handler_help(WINDOW *win); void invoke_autoruns(WINDOW *w, ToxWindow *self); -#endif /* #define API_H */ +#endif /* API_H */ diff --git a/src/audio_call.c b/src/audio_call.c index 46ac9cb..7b78ec8 100644 --- a/src/audio_call.c +++ b/src/audio_call.c @@ -54,8 +54,8 @@ /* compatibility with older versions of OpenAL */ #ifndef ALC_ALL_DEVICES_SPECIFIER #include -#endif -#endif +#endif /* ALC_ALL_DEVICES_SPECIFIER */ +#endif /* __APPLE__ */ extern FriendsList Friends; struct CallControl CallControl; @@ -997,4 +997,4 @@ void del_friend_AV(uint32_t index) CallControl.max_calls = index; } -#endif +#endif /* AUDIO */ diff --git a/src/audio_device.c b/src/audio_device.c index 7cbdef8..c4b55e1 100644 --- a/src/audio_device.c +++ b/src/audio_device.c @@ -38,8 +38,8 @@ /* compatibility with older versions of OpenAL */ #ifndef ALC_ALL_DEVICES_SPECIFIER #include -#endif /* ALC_ALL_DEVICES_SPECIFIER */ -#endif /* __APPLE__ */ +#endif /* ALC_ALL_DEVICES_SPECIFIER */ +#endif /* __APPLE__ */ #include #include diff --git a/src/autocomplete.c b/src/autocomplete.c index 5900a16..5f4e96c 100644 --- a/src/autocomplete.c +++ b/src/autocomplete.c @@ -29,7 +29,7 @@ #include #else #include -#endif /* ifdef __APPLE__ */ +#endif /* __APPLE__ */ #include "windows.h" #include "toxic.h" diff --git a/src/autocomplete.h b/src/autocomplete.h index 7c0c965..4c2c90d 100644 --- a/src/autocomplete.h +++ b/src/autocomplete.h @@ -39,4 +39,4 @@ int complete_line(ToxWindow *self, const void *list, size_t n_items, size_t size return diff between old len and new len of ctx->line, -1 if no matches or > 1 match */ int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd); -#endif /* #define AUTOCOMPLETE_H */ +#endif /* AUTOCOMPLETE_H */ diff --git a/src/bootstrap.h b/src/bootstrap.h index 3a07cdf..191cb2b 100644 --- a/src/bootstrap.h +++ b/src/bootstrap.h @@ -39,4 +39,4 @@ void do_tox_connection(Tox *m); */ int load_DHT_nodeslist(void); -#endif /* BOOTSTRAP_H */ +#endif /* BOOTSTRAP_H */ diff --git a/src/chat.c b/src/chat.c index 49a35ba..e0220a3 100644 --- a/src/chat.c +++ b/src/chat.c @@ -51,8 +51,8 @@ #include "audio_call.h" #ifdef VIDEO #include "video_call.h" -#endif /* VIDEO */ -#endif /* AUDIO */ +#endif /* VIDEO */ +#endif /* AUDIO */ extern char *DATA_FILE; extern FriendsList Friends; @@ -63,7 +63,7 @@ extern struct user_settings *user_settings; #ifdef AUDIO static void init_infobox(ToxWindow *self); static void kill_infobox(ToxWindow *self); -#endif /* AUDIO */ +#endif /* AUDIO */ #ifdef AUDIO #define AC_NUM_CHAT_COMMANDS_AUDIO 9 @@ -150,9 +150,9 @@ void kill_chat_window(ToxWindow *self, Tox *m) #ifdef AUDIO #ifdef VIDEO stop_video_stream(self); -#endif /* VIDEO */ +#endif /* VIDEO */ stop_current_call(self); -#endif /* AUDIO */ +#endif /* AUDIO */ kill_all_file_transfers_friend(m, self->num); log_disable(ctx->log); diff --git a/src/chat_commands.h b/src/chat_commands.h index 558410e..51041fd 100644 --- a/src/chat_commands.h +++ b/src/chat_commands.h @@ -49,4 +49,4 @@ void cmd_video(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE void cmd_ccur_video_device(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); #endif /* VIDEO */ -#endif /* #define CHAT_COMMANDS_H */ +#endif /* CHAT_COMMANDS_H */ diff --git a/src/configdir.h b/src/configdir.h index a5317c3..ab2d069 100644 --- a/src/configdir.h +++ b/src/configdir.h @@ -53,4 +53,4 @@ void get_home_dir(char *home, int size); */ int create_user_config_dirs(char *path); -#endif /* #define CONFIGDIR_H */ +#endif /* CONFIGDIR_H */ diff --git a/src/curl_util.h b/src/curl_util.h index cefb5db..2590308 100644 --- a/src/curl_util.h +++ b/src/curl_util.h @@ -52,4 +52,4 @@ int set_curl_proxy(CURL *c_handle, const char *proxy_address, uint16_t port, uin */ size_t curl_cb_write_data(void *data, size_t size, size_t nmemb, void *user_pointer); -#endif /* CURL_UTIL_H */ +#endif /* CURL_UTIL_H */ diff --git a/src/execute.h b/src/execute.h index 03c121b..67bebdf 100644 --- a/src/execute.h +++ b/src/execute.h @@ -36,4 +36,4 @@ enum { void execute(WINDOW *w, ToxWindow *self, Tox *m, const char *input, int mode); -#endif /* #define EXECUTE_H */ +#endif /* EXECUTE_H */ diff --git a/src/file_transfers.h b/src/file_transfers.h index 51104ef..a5ccdc2 100644 --- a/src/file_transfers.h +++ b/src/file_transfers.h @@ -108,4 +108,4 @@ void kill_all_file_transfers_friend(Tox *m, uint32_t friendnum); void kill_all_file_transfers(Tox *m); -#endif /* #define FILE_TRANSFERS_H */ +#endif /* FILE_TRANSFERS_H */ diff --git a/src/global_commands.h b/src/global_commands.h index a7b5eee..7453605 100644 --- a/src/global_commands.h +++ b/src/global_commands.h @@ -60,6 +60,6 @@ void cmd_change_video_device(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv #ifdef PYTHON void cmd_run(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); -#endif +#endif /* PYTHON */ -#endif /* #define GLOBAL_COMMANDS_H */ +#endif /* GLOBAL_COMMANDS_H */ diff --git a/src/group_commands.h b/src/group_commands.h index 5d9a1b6..b870cdd 100644 --- a/src/group_commands.h +++ b/src/group_commands.h @@ -28,4 +28,4 @@ void cmd_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); -#endif /* GROUP_COMMANDS_H */ +#endif /* GROUP_COMMANDS_H */ diff --git a/src/groupchat.c b/src/groupchat.c index b348759..0ce5a81 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -41,9 +41,9 @@ /* compatibility with older versions of OpenAL */ #ifndef ALC_ALL_DEVICES_SPECIFIER #include -#endif /* ALC_ALL_DEVICES_SPECIFIER */ -#endif /* __APPLE__ */ -#endif /* AUDIO */ +#endif /* ALC_ALL_DEVICES_SPECIFIER */ +#endif /* __APPLE__ */ +#endif /* AUDIO */ #include "windows.h" #include "toxic.h" diff --git a/src/groupchat.h b/src/groupchat.h index 5c5348d..6d77b47 100644 --- a/src/groupchat.h +++ b/src/groupchat.h @@ -63,4 +63,4 @@ void redraw_groupchat_win(ToxWindow *self); ToxWindow new_group_chat(Tox *m, uint32_t groupnum); -#endif /* #define GROUPCHAT_H */ +#endif /* GROUPCHAT_H */ diff --git a/src/help.c b/src/help.c index c7ef7cb..52b26e2 100644 --- a/src/help.c +++ b/src/help.c @@ -326,7 +326,7 @@ static void help_draw_plugin(ToxWindow *self) box(win, ACS_VLINE, ACS_HLINE); wnoutrefresh(win); } -#endif +#endif /* PYTHON */ static void help_draw_contacts(ToxWindow *self) { @@ -396,7 +396,7 @@ void help_onKey(ToxWindow *self, wint_t key) help_init_window(self, 4 + num_registered_handlers(), help_max_width()); self->help->type = HELP_PLUGIN; break; -#endif +#endif /* PYTHON */ case 'f': help_init_window(self, 10, 80); diff --git a/src/help.h b/src/help.h index b33ffba..4e7f6d6 100644 --- a/src/help.h +++ b/src/help.h @@ -42,4 +42,4 @@ void help_onDraw(ToxWindow *self); void help_init_menu(ToxWindow *self); void help_onKey(ToxWindow *self, wint_t key); -#endif /* #define HELP_H */ +#endif /* HELP_H */ diff --git a/src/input.h b/src/input.h index 72d6b3c..359dc7f 100644 --- a/src/input.h +++ b/src/input.h @@ -30,4 +30,4 @@ void input_new_char(ToxWindow *self, wint_t key, int x, int y, int mx_x, int mx_ return true if key matches a function, false otherwise */ bool input_handle(ToxWindow *self, wint_t key, int x, int y, int mx_x, int mx_y); -#endif /* #define INPUT_H */ +#endif /* INPUT_H */ diff --git a/src/line_info.h b/src/line_info.h index e80d1cb..3a95ec3 100644 --- a/src/line_info.h +++ b/src/line_info.h @@ -100,4 +100,4 @@ void line_info_reset_start(ToxWindow *self, struct history *hst); void line_info_init(struct history *hst); bool line_info_onKey(ToxWindow *self, wint_t key); /* returns true if key is a match */ -#endif /* #define LINE_INFO_H */ +#endif /* LINE_INFO_H */ diff --git a/src/log.h b/src/log.h index 1ebbc83..2a3fd2a 100644 --- a/src/log.h +++ b/src/log.h @@ -56,4 +56,4 @@ void load_chat_history(ToxWindow *self, struct chatlog *log); Returns 0 on success or if no log exists, -1 on failure. */ int rename_logfile(char *src, char *dest, const char *selfkey, const char *otherkey, int winnum); -#endif /* #define LOG_H */ +#endif /* LOG_H */ diff --git a/src/message_queue.h b/src/message_queue.h index 8cc353c..7c9bbb0 100644 --- a/src/message_queue.h +++ b/src/message_queue.h @@ -48,4 +48,4 @@ void cqueue_try_send(ToxWindow *self, Tox *m); /* removes message with matching receipt from queue, writes to log and updates line to show the message was received. */ void cqueue_remove(ToxWindow *self, Tox *m, uint32_t receipt); -#endif /* #define MESSAGE_QUEUE_H */ +#endif /* MESSAGE_QUEUE_H */ diff --git a/src/misc_tools.h b/src/misc_tools.h index a7c964f..8f786a4 100644 --- a/src/misc_tools.h +++ b/src/misc_tools.h @@ -170,4 +170,4 @@ bool is_ip4_address(const char *address); */ bool is_ip6_address(const char *address); -#endif /* #define MISC_TOOLS_H */ +#endif /* MISC_TOOLS_H */ diff --git a/src/notify.c b/src/notify.c index aaddbbf..0750700 100644 --- a/src/notify.c +++ b/src/notify.c @@ -47,12 +47,12 @@ /* compatibility with older versions of OpenAL */ #ifndef ALC_ALL_DEVICES_SPECIFIER #include -#endif -#endif +#endif /* ALC_ALL_DEVICES_SPECIFIER */ +#endif /* __APPLE__ */ #ifdef SOUND_NOTIFY #include /* freealut packet */ -#endif -#endif /* AUDIO */ +#endif /* SOUND_NOTIFY */ +#endif /* defined(AUDIO) || defined(SOUND_NOTIFY) */ #ifdef BOX_NOTIFY #include @@ -84,7 +84,7 @@ static struct _ActiveNotifications { uint32_t source; uint32_t buffer; bool looping; -#endif +#endif /* SOUND_NOTIFY */ bool active; int *id_indicator; #ifdef BOX_NOTIFY @@ -93,7 +93,7 @@ static struct _ActiveNotifications { char title[64]; size_t size; time_t n_timeout; -#endif +#endif /* BOX_NOTIFY */ } actives[ACTIVE_NOTIFS_MAX]; /**********************************************************************************/ /**********************************************************************************/ @@ -203,7 +203,7 @@ void graceful_clear(void) actives[i].box = NULL; } -#endif +#endif /* BOX_NOTIFY */ if (actives[i].id_indicator) { *actives[i].id_indicator = -1; /* reset indicator value */ @@ -293,7 +293,7 @@ void *do_playing(void *_p) } } -#endif +#endif /* BOX_NOTIFY */ } /* device is opened and no activity in under DEVICE_COOLDOWN time, close device*/ @@ -388,7 +388,7 @@ void graceful_clear(void) control_unlock(); } -#endif +#endif /* SOUND_NOTIFY */ /**********************************************************************************/ /**********************************************************************************/ @@ -420,7 +420,7 @@ int init_notify(int login_cooldown, int notification_timeout) return -1; } -#endif +#endif /* defined(SOUND_NOTIFY) || defined(BOX_NOTIFY) */ Control.cooldown = time(NULL) + login_cooldown; @@ -445,7 +445,7 @@ void terminate_notify(void) control_unlock(); graceful_clear(); -#endif +#endif /* defined(SOUND_NOTIFY) || defined(BOX_NOTIFY) */ #ifdef SOUND_NOTIFY int i = 0; @@ -534,20 +534,20 @@ void stop_sound(int id) notify_notification_close(actives[id].box, &ignore); } -#endif +#endif /* BOX_NOTIFY */ if (actives[id].id_indicator) { *actives[id].id_indicator = -1; } -// alSourcei(actives[id].source, AL_LOOPING, false); + // alSourcei(actives[id].source, AL_LOOPING, false); alSourceStop(actives[id].source); alDeleteSources(1, &actives[id].source); alDeleteBuffers(1, &actives[id].buffer); memset(&actives[id], 0, sizeof(struct _ActiveNotifications)); } } -#endif +#endif /* SOUND_NOTIFY */ static int m_play_sound(Notification notif, uint64_t flags) { @@ -563,12 +563,6 @@ static int m_play_sound(Notification notif, uint64_t flags) #endif /* SOUND_NOTIFY */ } -#ifdef BOX_NOTIFY -void m_notify_action(NotifyNotification *box, char *action, void *data) -{ -} -#endif - int sound_notify(ToxWindow *self, Notification notif, uint64_t flags, int *id_indicator) { tab_notify(self, flags); @@ -597,7 +591,7 @@ int sound_notify(ToxWindow *self, Notification notif, uint64_t flags, int *id_in } } -#endif +#endif /* defined(BOX_NOTIFY) && !defined(SOUND_NOTIFY) */ if (id_indicator && id != -1) { actives[id].id_indicator = id_indicator; @@ -695,7 +689,7 @@ int box_notify(ToxWindow *self, Notification notif, uint64_t flags, int *id_indi return -1; } -#endif /* SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ snprintf(actives[id].title, sizeof(actives[id].title), "%s", title); @@ -725,7 +719,7 @@ int box_notify(ToxWindow *self, Notification notif, uint64_t flags, int *id_indi return id; #else return sound_notify(self, notif, flags, id_indicator); -#endif /* BOX_NOTIFY */ +#endif /* BOX_NOTIFY */ } int box_notify2(ToxWindow *self, Notification notif, uint64_t flags, int id, const char *format, ...) @@ -779,7 +773,7 @@ int box_notify2(ToxWindow *self, Notification notif, uint64_t flags, int id, con return id; #else return sound_notify2(self, notif, flags, id); -#endif +#endif /* BOX_NOTIFY */ } int box_silent_notify(ToxWindow *self, uint64_t flags, int *id_indicator, const char *title, const char *format, ...) @@ -837,7 +831,7 @@ int box_silent_notify(ToxWindow *self, uint64_t flags, int *id_indicator, const return id; #else return -1; -#endif +#endif /* BOX_NOTIFY */ } int box_silent_notify2(ToxWindow *self, uint64_t flags, int id, const char *format, ...) @@ -888,5 +882,5 @@ int box_silent_notify2(ToxWindow *self, uint64_t flags, int id, const char *form return id; #else return -1; -#endif +#endif /* BOX_NOTIFY */ } diff --git a/src/python_api.h b/src/python_api.h index 3f41e8c..2f8c5e6 100644 --- a/src/python_api.h +++ b/src/python_api.h @@ -36,4 +36,4 @@ int python_num_registered_handlers(void); int python_help_max_width(void); void python_draw_handler_help(WINDOW *win); -#endif /* #define PYTHON_API_H */ +#endif /* PYTHON_API_H */ diff --git a/src/settings.h b/src/settings.h index c0d74dd..4d65e4d 100644 --- a/src/settings.h +++ b/src/settings.h @@ -125,4 +125,5 @@ enum settings_values { #define MPLEX_AWAY_NOTE "Detached from screen" int settings_load(struct user_settings *s, const char *patharg); -#endif /* #define SETTINGS_H */ + +#endif /* SETTINGS_H */ diff --git a/src/term_mplex.h b/src/term_mplex.h index 0128291..39cceaf 100644 --- a/src/term_mplex.h +++ b/src/term_mplex.h @@ -24,12 +24,12 @@ #define TERM_MPLEX_H /* Checks if Toxic runs inside a terminal multiplexer (GNU screen or tmux). If - yes, it initializes a timer which periodically checks the attached/detached - state of the terminal and updates away status accordingly. + * yes, it initializes a timer which periodically checks the attached/detached + * state of the terminal and updates away status accordingly. */ int init_mplex_away_timer(Tox *m); void lock_status(void); void unlock_status(void); -#endif /* #define TERM_MPLEX_H */ +#endif /* TERM_MPLEX_H */ diff --git a/src/toxic.c b/src/toxic.c index 3554eac..efa27a9 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -900,7 +900,7 @@ void *thread_av(void *data) usleep(toxav_iteration_interval(av) * 1000); } } -#endif /* AUDIO */ +#endif /* AUDIO */ static void print_usage(void) { @@ -1273,7 +1273,7 @@ int main(int argc, char **argv) queue_init_message("X failed to initialize"); } -#endif +#endif /* X11 */ Tox *m = load_toxic(DATA_FILE); diff --git a/src/toxic.h b/src/toxic.h index b437e82..103402f 100644 --- a/src/toxic.h +++ b/src/toxic.h @@ -133,4 +133,4 @@ void on_file_recv(Tox *m, uint32_t friendnumber, uint32_t filenumber, uint32_t k void on_friend_typing(Tox *m, uint32_t friendnumber, bool is_typing, void *userdata); void on_friend_read_receipt(Tox *m, uint32_t friendnumber, uint32_t receipt, void *userdata); -#endif /* #define TOXIC_H */ +#endif /* TOXIC_H */ diff --git a/src/toxic_strings.h b/src/toxic_strings.h index 11e7c1b..c9cbe05 100644 --- a/src/toxic_strings.h +++ b/src/toxic_strings.h @@ -70,4 +70,4 @@ void fetch_hist_item(ChatContext *ctx, int key_dir); void strsubst(char *str, char old, char new); void wstrsubst(wchar_t *str, wchar_t old, wchar_t new); -#endif /* #define TOXIC_STRINGS_H */ +#endif /* TOXIC_STRINGS_H */ diff --git a/src/video_call.c b/src/video_call.c index 45ec34e..92e5df7 100644 --- a/src/video_call.c +++ b/src/video_call.c @@ -447,4 +447,4 @@ void stop_video_stream(ToxWindow *self) } } -#endif +#endif /* VIDEO */ diff --git a/src/video_device.c b/src/video_device.c index c1e2a6d..49ca9fc 100644 --- a/src/video_device.c +++ b/src/video_device.c @@ -41,8 +41,8 @@ #include #else #include -#endif -#endif +#endif /* defined(__OpenBSD__) || defined(__NetBSD__) */ +#endif /* __OSX__ */ #include "line_info.h" #include "settings.h" diff --git a/src/windows.c b/src/windows.c index 1dc6bf7..fae0552 100644 --- a/src/windows.c +++ b/src/windows.c @@ -487,7 +487,7 @@ void on_window_resize(void) w->chatwin->infobox.win = newwin(INFOBOX_HEIGHT, INFOBOX_WIDTH + 1, 1, x2 - INFOBOX_WIDTH); } -#endif /* AUDIO */ +#endif /* AUDIO */ scrollok(w->chatwin->history, 0); } diff --git a/src/windows.h b/src/windows.h index 7dc6932..bdfba08 100644 --- a/src/windows.h +++ b/src/windows.h @@ -266,4 +266,4 @@ ToxWindow *get_active_window(void); call at least once per second */ void refresh_inactive_windows(void); -#endif /* #define WINDOWS_H */ +#endif /* WINDOWS_H */