From 133c0e8d63bda210b23fa64dffefcd0dd5fe47d6 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Mon, 22 Sep 2014 21:24:45 -0400 Subject: [PATCH] rename reserved identifiers per C standard --- src/audio_call.c | 25 +++++------ src/audio_call.h | 6 +-- src/autocomplete.h | 6 +-- src/chat.c | 84 ++++++++++++++++++------------------- src/chat.h | 6 +-- src/chat_commands.h | 10 ++--- src/configdir.h | 6 +-- src/device.c | 43 +++++++++---------- src/device.h | 17 ++++---- src/dns.c | 2 +- src/dns.h | 6 +-- src/execute.c | 8 ++-- src/execute.h | 6 +-- src/file_senders.h | 6 +-- src/friendlist.c | 20 ++++----- src/friendlist.h | 6 +-- src/global_commands.c | 4 +- src/global_commands.h | 10 ++--- src/groupchat.c | 8 ++-- src/groupchat.h | 6 +-- src/help.c | 12 +++--- src/help.h | 6 +-- src/input.h | 6 +-- src/line_info.c | 14 +++---- src/line_info.h | 6 +-- src/log.c | 8 ++-- src/log.h | 6 +-- src/message_queue.h | 5 +++ src/misc_tools.c | 6 +-- src/misc_tools.h | 6 +-- src/notify.c | 98 +++++++++++++++++++++---------------------- src/notify.h | 10 ++--- src/prompt.c | 12 +++--- src/prompt.h | 14 +++---- src/settings.c | 24 +++++------ src/settings.h | 8 ++-- src/toxic.c | 52 +++++++++++------------ src/toxic.h | 6 +-- src/toxic_strings.h | 6 +-- src/windows.c | 14 +++---- src/windows.h | 24 +++++------ 41 files changed, 316 insertions(+), 312 deletions(-) diff --git a/src/audio_call.c b/src/audio_call.c index 37d4eb9..e5cf617 100644 --- a/src/audio_call.c +++ b/src/audio_call.c @@ -29,6 +29,7 @@ #include "line_info.h" #include "notify.h" +#include #include #include #include @@ -48,27 +49,27 @@ #endif #endif -#define _cbend pthread_exit(NULL) +#define cbend pthread_exit(NULL) #define MAX_CALLS 10 #define frame_size (av_DefaultSettings.audio_sample_rate * av_DefaultSettings.audio_frame_duration / 1000) -typedef struct _Call { +typedef struct Call { pthread_t ttid; /* Transmission thread id */ - _Bool ttas, has_output; /* Transmission thread active status (0 - stopped, 1- running) */ + bool ttas, has_output; /* Transmission thread active status (0 - stopped, 1- running) */ uint32_t in_idx, out_idx; pthread_mutex_t mutex; } Call; -void set_call(Call* call, _Bool start) +void set_call(Call* call, bool start) { call->in_idx = -1; call->out_idx = -1; if ( start ) { - call->ttas = _True; + call->ttas = true; pthread_mutex_init(&call->mutex, NULL); } else { @@ -77,7 +78,7 @@ void set_call(Call* call, _Bool start) } } -struct _ASettings { +struct ASettings { AudioError errors; ToxAv *av; @@ -198,7 +199,7 @@ int start_transmission(ToxWindow *self) !toxav_capability_supported(ASettins.av, self->call_idx, AudioEncoding) ) return -1; - set_call(&ASettins.calls[self->call_idx], _True); + set_call(&ASettins.calls[self->call_idx], true); ToxAvCSettings csettings; toxav_get_peer_csettings(ASettins.av, self->call_idx, 0, &csettings); @@ -208,7 +209,7 @@ int start_transmission(ToxWindow *self) line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to open input device!"); if ( register_device_callback(self->call_idx, ASettins.calls[self->call_idx].in_idx, - read_device_callback, &self->call_idx, _True) != de_None) + read_device_callback, &self->call_idx, true) != de_None) /* Set VAD as true for all; TODO: Make it more dynamic */ line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to register input handler!"); @@ -225,7 +226,7 @@ int stop_transmission(int call_index) { if ( ASettins.calls[call_index].ttas ) { toxav_kill_transmission(ASettins.av, call_index); - ASettins.calls[call_index].ttas = _False; + ASettins.calls[call_index].ttas = false; if ( ASettins.calls[call_index].in_idx != -1 ) close_device(input, ASettins.calls[call_index].in_idx); @@ -233,7 +234,7 @@ int stop_transmission(int call_index) if ( ASettins.calls[call_index].out_idx != -1 ) close_device(output, ASettins.calls[call_index].out_idx); - set_call(&ASettins.calls[call_index], _False); + set_call(&ASettins.calls[call_index], false); return 0; } @@ -452,7 +453,7 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[ if (toxav_get_call_state(ASettins.av, self->call_idx) == av_CallInviting) { error = toxav_cancel(ASettins.av, self->call_idx, self->num, "Only those who appreciate small things know the beauty that is life"); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); #endif line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call canceled!"); @@ -610,7 +611,7 @@ void cmd_ccur_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*a open_device(input, selection, &this_call->in_idx, csettings.audio_sample_rate, csettings.audio_frame_duration, csettings.audio_channels); /* Set VAD as true for all; TODO: Make it more dynamic */ - register_device_callback(self->call_idx, this_call->in_idx, read_device_callback, &self->call_idx, _True); + register_device_callback(self->call_idx, this_call->in_idx, read_device_callback, &self->call_idx, true); } } } diff --git a/src/audio_call.h b/src/audio_call.h index 5844c65..d127a00 100644 --- a/src/audio_call.h +++ b/src/audio_call.h @@ -20,8 +20,8 @@ * */ -#ifndef _audio_h -#define _audio_h +#ifndef AUDIO_H +#define AUDIO_H #include @@ -42,4 +42,4 @@ void terminate_audio(); void stop_current_call(ToxWindow *self); -#endif /* _audio_h */ +#endif /* AUDIO_H */ diff --git a/src/autocomplete.h b/src/autocomplete.h index 75d5c75..40b7099 100644 --- a/src/autocomplete.h +++ b/src/autocomplete.h @@ -20,8 +20,8 @@ * */ -#ifndef _autocomplete_h -#define _autocomplete_h +#ifndef AUTOCOMPLETE_H +#define AUTOCOMPLETE_H /* looks for all instances in list that begin with the last entered word in line according to pos, then fills line with the complete word. e.g. "Hello jo" would complete the line @@ -39,4 +39,4 @@ int complete_line(ToxWindow *self, const void *list, int n_items, int 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); -#endif /* #define _autocomplete_h */ \ No newline at end of file +#endif /* #define AUTOCOMPLETE_H */ \ No newline at end of file diff --git a/src/chat.c b/src/chat.c index 190bfb1..81e659e 100644 --- a/src/chat.c +++ b/src/chat.c @@ -45,9 +45,9 @@ #include "notify.h" #include "message_queue.h" -#ifdef _AUDIO +#ifdef AUDIO #include "audio_call.h" -#endif /* _AUDIO */ +#endif /* AUDIO */ extern char *DATA_FILE; @@ -55,19 +55,19 @@ extern char *DATA_FILE; extern FileSender file_senders[MAX_FILES]; extern _Friends Friends; -extern struct _Winthread Winthread; -extern struct user_settings *user_settings_; +extern struct Winthread Winthread; +extern struct user_settings *user_settings; -#ifdef _AUDIO +#ifdef AUDIO static void init_infobox(ToxWindow *self); static void kill_infobox(ToxWindow *self); -#endif /* _AUDIO */ +#endif /* AUDIO */ -#ifdef _AUDIO +#ifdef AUDIO #define AC_NUM_CHAT_COMMANDS 26 #else #define AC_NUM_CHAT_COMMANDS 19 -#endif /* _AUDIO */ +#endif /* AUDIO */ /* Array of chat command names used for tab completion. */ static const char chat_cmd_list[AC_NUM_CHAT_COMMANDS][MAX_CMDNAME_SIZE] = { @@ -91,7 +91,7 @@ static const char chat_cmd_list[AC_NUM_CHAT_COMMANDS][MAX_CMDNAME_SIZE] = { { "/sendfile" }, { "/status" }, -#ifdef _AUDIO +#ifdef AUDIO { "/call" }, { "/answer" }, @@ -101,12 +101,12 @@ static const char chat_cmd_list[AC_NUM_CHAT_COMMANDS][MAX_CMDNAME_SIZE] = { { "/mute" }, { "/sense" }, -#endif /* _AUDIO */ +#endif /* AUDIO */ }; static void set_self_typingstatus(ToxWindow *self, Tox *m, uint8_t is_typing) { - if (user_settings_->show_typing_self == SHOW_TYPING_OFF) + if (user_settings->show_typing_self == SHOW_TYPING_OFF) return; ChatContext *ctx = self->chatwin; @@ -137,7 +137,7 @@ void kill_chat_window(ToxWindow *self, Tox *m) line_info_cleanup(ctx->hst); cqueue_cleanup(ctx->cqueue); -#ifdef _AUDIO +#ifdef AUDIO stop_current_call(self); #endif @@ -197,7 +197,7 @@ static void chat_onConnectionChange(ToxWindow *self, Tox *m, int32_t num, uint8_ if (status == 1) { /* Friend goes online */ statusbar->is_online = true; - Friends.list[num].is_typing = user_settings_->show_typing_other == SHOW_TYPING_ON + Friends.list[num].is_typing = user_settings->show_typing_other == SHOW_TYPING_ON ? tox_get_is_typing(m, num) : 0; chat_resume_file_transfers(m, num); @@ -317,9 +317,9 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t } /* use specified path in config if possible */ - if (user_settings_->download_path[0]) { - snprintf(filename_path, sizeof(filename_path), "%s%s", user_settings_->download_path, filename_nopath); - len += strlen(user_settings_->download_path); + if (user_settings->download_path[0]) { + snprintf(filename_path, sizeof(filename_path), "%s%s", user_settings->download_path, filename_nopath); + len += strlen(user_settings->download_path); } if (len >= sizeof(Friends.list[num].file_receiver[filenum].filename)) { @@ -582,7 +582,7 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, co } /* Av Stuff */ -#ifdef _AUDIO +#ifdef AUDIO void chat_onInvite (ToxWindow *self, ToxAv *av, int call_index) { @@ -611,10 +611,10 @@ void chat_onRinging (ToxWindow *self, ToxAv *av, int call_index) line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ringing...type \"/hangup\" to cancel it."); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY if (self->ringing_sound == -1) sound_notify(self, call_outgoing, NT_LOOP, &self->ringing_sound); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } void chat_onStarting (ToxWindow *self, ToxAv *av, int call_index) @@ -626,9 +626,9 @@ void chat_onStarting (ToxWindow *self, ToxAv *av, int call_index) line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it."); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } void chat_onEnding (ToxWindow *self, ToxAv *av, int call_index) @@ -640,9 +640,9 @@ void chat_onEnding (ToxWindow *self, ToxAv *av, int call_index) self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!"); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } void chat_onError (ToxWindow *self, ToxAv *av, int call_index) @@ -653,9 +653,9 @@ void chat_onError (ToxWindow *self, ToxAv *av, int call_index) self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Error!"); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } void chat_onStart (ToxWindow *self, ToxAv *av, int call_index) @@ -667,9 +667,9 @@ void chat_onStart (ToxWindow *self, ToxAv *av, int call_index) line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it."); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } void chat_onCancel (ToxWindow *self, ToxAv *av, int call_index) @@ -681,9 +681,9 @@ void chat_onCancel (ToxWindow *self, ToxAv *av, int call_index) self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call canceled!"); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } void chat_onReject (ToxWindow *self, ToxAv *av, int call_index) @@ -694,9 +694,9 @@ void chat_onReject (ToxWindow *self, ToxAv *av, int call_index) self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Rejected!"); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } void chat_onEnd (ToxWindow *self, ToxAv *av, int call_index) @@ -708,9 +708,9 @@ void chat_onEnd (ToxWindow *self, ToxAv *av, int call_index) self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!"); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } void chat_onRequestTimeout (ToxWindow *self, ToxAv *av, int call_index) @@ -721,9 +721,9 @@ void chat_onRequestTimeout (ToxWindow *self, ToxAv *av, int call_index) self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No answer!"); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } void chat_onPeerTimeout (ToxWindow *self, ToxAv *av, int call_index) @@ -735,9 +735,9 @@ void chat_onPeerTimeout (ToxWindow *self, ToxAv *av, int call_index) self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer disconnected; call ended!"); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } static void init_infobox(ToxWindow *self) @@ -752,7 +752,7 @@ static void init_infobox(ToxWindow *self) ctx->infobox.win = newwin(INFOBOX_HEIGHT, INFOBOX_WIDTH + 1, 1, x2 - INFOBOX_WIDTH); ctx->infobox.starttime = get_unix_time(); - ctx->infobox.vad_lvl = user_settings_->VAD_treshold; + ctx->infobox.vad_lvl = user_settings->VAD_treshold; ctx->infobox.active = true; strcpy(ctx->infobox.timestr, "00"); } @@ -822,7 +822,7 @@ static void draw_infobox(ToxWindow *self) wrefresh(infobox->win); } -#endif /* _AUDIO */ +#endif /* AUDIO */ static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, char *action) { @@ -1040,7 +1040,7 @@ static void chat_onDraw(ToxWindow *self, Tox *m) wrefresh(self->window); -#ifdef _AUDIO +#ifdef AUDIO if (ctx->infobox.active) { draw_infobox(self); wrefresh(self->window); @@ -1130,7 +1130,7 @@ ToxWindow new_chat(Tox *m, int32_t friendnum) ret.onFileData = &chat_onFileData; ret.onReadReceipt = &chat_onReadReceipt; -#ifdef _AUDIO +#ifdef AUDIO ret.onInvite = &chat_onInvite; ret.onRinging = &chat_onRinging; ret.onStarting = &chat_onStarting; @@ -1146,7 +1146,7 @@ ToxWindow new_chat(Tox *m, int32_t friendnum) ret.call_idx = -1; ret.device_selection[0] = ret.device_selection[1] = -1; ret.ringing_sound = -1; -#endif /* _AUDIO */ +#endif /* AUDIO */ ret.active_box = -1; diff --git a/src/chat.h b/src/chat.h index b8f6e88..783f78c 100644 --- a/src/chat.h +++ b/src/chat.h @@ -20,8 +20,8 @@ * */ -#ifndef CHAT_H_6489PZ13 -#define CHAT_H_6489PZ13 +#ifndef CHAT_H +#define CHAT_H #include "windows.h" #include "toxic.h" @@ -32,4 +32,4 @@ void chat_close_file_receiver(Tox *m, int filenum, int friendnum, int CTRL); void kill_chat_window(ToxWindow *self, Tox *m); ToxWindow new_chat(Tox *m, int32_t friendnum); -#endif /* end of include guard: CHAT_H_6489PZ13 */ +#endif /* end of include guard: CHAT_H */ diff --git a/src/chat_commands.h b/src/chat_commands.h index a3ade6e..c66b77a 100644 --- a/src/chat_commands.h +++ b/src/chat_commands.h @@ -20,8 +20,8 @@ * */ -#ifndef _chat_commands_h -#define _chat_commands_h +#ifndef CHAT_COMMANDS_H +#define CHAT_COMMANDS_H #include "windows.h" #include "toxic.h" @@ -32,7 +32,7 @@ void cmd_join_group(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR void cmd_savefile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_sendfile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); -#ifdef _AUDIO +#ifdef AUDIO void cmd_call(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_answer(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_reject(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); @@ -41,6 +41,6 @@ void cmd_cancel(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZ void cmd_ccur_device(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_mute(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_sense(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); -#endif /* _AUDIO */ +#endif /* AUDIO */ -#endif /* #define _chat_commands_h */ +#endif /* #define CHAT_COMMANDS_H */ diff --git a/src/configdir.h b/src/configdir.h index aa430c5..69abffd 100644 --- a/src/configdir.h +++ b/src/configdir.h @@ -20,8 +20,8 @@ * */ -#ifndef _configdir_h -#define _configdir_h +#ifndef CONFIGDIR_H +#define CONFIGDIR_H #ifndef NSS_BUFLEN_PASSWD #define NSS_BUFLEN_PASSWD 4096 @@ -38,4 +38,4 @@ char *get_user_config_dir(void); void get_home_dir(char *home, int size); int create_user_config_dirs(char *path); -#endif /* #define _configdir_h */ +#endif /* #define CONFIGDIR_H */ diff --git a/src/device.c b/src/device.c index 16114de..e3ec4f4 100644 --- a/src/device.c +++ b/src/device.c @@ -22,7 +22,7 @@ #include "device.h" -#ifdef _AUDIO +#ifdef AUDIO #include "audio_call.h" #endif @@ -41,6 +41,7 @@ #endif #endif +#include #include #include #include @@ -50,9 +51,9 @@ #define OPENAL_BUFS 5 #define inline__ inline __attribute__((always_inline)) -extern struct user_settings *user_settings_; +extern struct user_settings *user_settings; -typedef struct _Device { +typedef struct Device { ALCdevice *dhndl; /* Handle of device selected/opened */ ALCcontext *ctx; /* Device context */ DataHandleCallback cb; /* Use this to handle data from input device usually */ @@ -62,13 +63,13 @@ typedef struct _Device { uint32_t source, buffers[OPENAL_BUFS]; /* Playback source/buffers */ size_t ref_count; int32_t selection; - _Bool enable_VAD; - _Bool muted; + bool enable_VAD; + bool muted; pthread_mutex_t mutex[1]; uint32_t sample_rate; uint32_t frame_duration; int32_t sound_mode; -#ifdef _AUDIO +#ifdef AUDIO float VAD_treshold; /* 40 is usually recommended value */ #endif } Device; @@ -79,9 +80,9 @@ static int size[2]; /* Size of above containers */ Device *running[2][MAX_DEVICES]; /* Running devices */ uint32_t primary_device[2]; /* Primary device */ -#ifdef _AUDIO +#ifdef AUDIO static ToxAv* av = NULL; -#endif /* _AUDIO */ +#endif /* AUDIO */ /* q_mutex */ #define lock pthread_mutex_lock(&mutex) @@ -89,16 +90,16 @@ static ToxAv* av = NULL; pthread_mutex_t mutex; -_Bool thread_running = _True, - thread_paused = _True; /* Thread control */ +bool thread_running = true, + thread_paused = true; /* Thread control */ void* thread_poll(void*); /* Meet devices */ -#ifdef _AUDIO +#ifdef AUDIO DeviceError init_devices(ToxAv* av_) #else DeviceError init_devices() -#endif /* _AUDIO */ +#endif /* AUDIO */ { const char *stringed_device_list; @@ -134,9 +135,9 @@ DeviceError init_devices() if ( pthread_create(&thread_id, NULL, thread_poll, NULL) != 0 || pthread_detach(thread_id) != 0) return de_InternalError; -#ifdef _AUDIO +#ifdef AUDIO av = av_; -#endif /* _AUDIO */ +#endif /* AUDIO */ return (DeviceError) de_None; } @@ -170,7 +171,7 @@ DeviceError device_mute(DeviceType type, uint32_t device_idx) return de_None; } -#ifdef _AUDIO +#ifdef AUDIO DeviceError device_set_VAD_treshold(uint32_t device_idx, float value) { if (device_idx >= MAX_DEVICES) return de_InvalidSelection; @@ -247,8 +248,8 @@ DeviceError open_device(DeviceType type, int32_t selection, uint32_t* device_idx if (type == input) { device->dhndl = alcCaptureOpenDevice(devices_names[type][selection], sample_rate, device->sound_mode, frame_size * 2); - #ifdef _AUDIO - device->VAD_treshold = user_settings_->VAD_treshold; + #ifdef AUDIO + device->VAD_treshold = user_settings->VAD_treshold; #endif } else { @@ -287,7 +288,7 @@ DeviceError open_device(DeviceType type, int32_t selection, uint32_t* device_idx if (type == input) { alcCaptureStart(device->dhndl); - thread_paused = _False; + thread_paused = false; } pthread_mutex_init(device->mutex, NULL); @@ -336,7 +337,7 @@ DeviceError close_device(DeviceType type, uint32_t device_idx) return de_None; } -DeviceError register_device_callback( int32_t call_idx, uint32_t device_idx, DataHandleCallback callback, void* data, _Bool enable_VAD) +DeviceError register_device_callback( int32_t call_idx, uint32_t device_idx, DataHandleCallback callback, void* data, bool enable_VAD) { if (size[input] <= device_idx || !running[input][device_idx] || running[input][device_idx]->dhndl == NULL) return de_InvalidSelection; @@ -427,9 +428,9 @@ void* thread_poll (void* arg) // TODO: maybe use thread for every input source alcCaptureSamples(device->dhndl, frame, f_size); if ( device->muted - #ifdef _AUDIO + #ifdef AUDIO || (device->enable_VAD && !toxav_has_activity(av, device->call_idx, frame, f_size, device->VAD_treshold)) - #endif /* _AUDIO */ + #endif /* AUDIO */ ) { unlock; continue; } /* Skip if no voice activity */ diff --git a/src/device.h b/src/device.h index 8ec3b57..29cacf7 100644 --- a/src/device.h +++ b/src/device.h @@ -26,16 +26,13 @@ * Read from running input device(s) via select()/callback combo. */ -#ifndef _device_h -#define _device_h +#ifndef DEVICE_H +#define DEVICE_H #define MAX_DEVICES 32 #include #include "windows.h" -#define _True 1 -#define _False 0 - typedef enum DeviceType { input, output, @@ -57,22 +54,22 @@ typedef enum DeviceError { typedef void (*DataHandleCallback) (const int16_t*, uint32_t size, void* data); -#ifdef _AUDIO +#ifdef AUDIO DeviceError init_devices(ToxAv* av); #else DeviceError init_devices(); -#endif /* _AUDIO */ +#endif /* AUDIO */ DeviceError terminate_devices(); /* Callback handles ready data from INPUT device */ -DeviceError register_device_callback(int32_t call_idx, uint32_t device_idx, DataHandleCallback callback, void* data, _Bool enable_VAD); +DeviceError register_device_callback(int32_t call_idx, uint32_t device_idx, DataHandleCallback callback, void* data, bool enable_VAD); void* get_device_callback_data(uint32_t device_idx); /* toggle device mute */ DeviceError device_mute(DeviceType type, uint32_t device_idx); -#ifdef _AUDIO +#ifdef AUDIO DeviceError device_set_VAD_treshold(uint32_t device_idx, float value); #endif @@ -89,4 +86,4 @@ DeviceError write_out(uint32_t device_idx, int16_t* data, uint32_t lenght, uint8 void print_devices(ToxWindow* self, DeviceType type); DeviceError selection_valid(DeviceType type, int32_t selection); -#endif /* _device_h */ +#endif /* DEVICE_H */ diff --git a/src/dns.c b/src/dns.c index 18346b7..675d27f 100644 --- a/src/dns.c +++ b/src/dns.c @@ -46,7 +46,7 @@ #define MAX_DNS_REQST_SIZE 255 #define TOX_DNS3_TXT_PREFIX "v=tox3;id=" -extern struct _Winthread Winthread; +extern struct Winthread Winthread; extern struct _dns3_servers dns3_servers; extern struct arg_opts arg_opts; diff --git a/src/dns.h b/src/dns.h index 1329820..9e6852e 100644 --- a/src/dns.h +++ b/src/dns.h @@ -23,10 +23,10 @@ /* Does DNS lookup for addr and puts resulting tox id in id_bin. Return 0 on success, -1 on failure. */ -#ifndef _dns_h -#define _dns_h +#ifndef DNS_H +#define DNS_H /* creates new thread for dns3 lookup. Only allows one lookup at a time. */ void dns3_lookup(ToxWindow *self, Tox *m, const char *id_bin, const char *addr, const char *msg); -#endif /* #define _dns_h */ +#endif /* #define DNS_H */ diff --git a/src/execute.c b/src/execute.c index a9957ba..0a85c90 100644 --- a/src/execute.c +++ b/src/execute.c @@ -55,10 +55,10 @@ static struct cmd_func global_commands[] = { { "/quit", cmd_quit }, { "/requests", cmd_requests }, { "/status", cmd_status }, -#ifdef _AUDIO +#ifdef AUDIO { "/lsdev", cmd_list_devices }, { "/sdev", cmd_change_device }, -#endif /* _AUDIO */ +#endif /* AUDIO */ { NULL, NULL }, }; @@ -68,7 +68,7 @@ static struct cmd_func chat_commands[] = { { "/join", cmd_join_group }, { "/savefile", cmd_savefile }, { "/sendfile", cmd_sendfile }, -#ifdef _AUDIO +#ifdef AUDIO { "/call", cmd_call }, { "/answer", cmd_answer }, { "/reject", cmd_reject }, @@ -76,7 +76,7 @@ static struct cmd_func chat_commands[] = { { "/sdev", cmd_ccur_device }, { "/mute", cmd_mute }, { "/sense", cmd_sense }, -#endif /* _AUDIO */ +#endif /* AUDIO */ { NULL, NULL }, }; diff --git a/src/execute.h b/src/execute.h index c63b639..03c121b 100644 --- a/src/execute.h +++ b/src/execute.h @@ -20,8 +20,8 @@ * */ -#ifndef _execute_h -#define _execute_h +#ifndef EXECUTE_H +#define EXECUTE_H #include "toxic.h" #include "windows.h" @@ -36,4 +36,4 @@ enum { void execute(WINDOW *w, ToxWindow *self, Tox *m, const char *input, int mode); -#endif /* #define _execute_h */ +#endif /* #define EXECUTE_H */ diff --git a/src/file_senders.h b/src/file_senders.h index 90c7e1f..479d855 100644 --- a/src/file_senders.h +++ b/src/file_senders.h @@ -20,8 +20,8 @@ * */ -#ifndef _filesenders_h -#define _filesenders_h +#ifndef FILESENDERS_H +#define FILESENDERS_H #include "toxic.h" #include "windows.h" @@ -72,4 +72,4 @@ void reset_file_sender_queue(void); void close_all_file_senders(Tox *m); void do_file_senders(Tox *m); -#endif /* #define _filesenders_h */ +#endif /* #define FILESENDERS_H */ diff --git a/src/friendlist.c b/src/friendlist.c index 01ca0a5..7fb4412 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -38,7 +38,7 @@ #include "notify.h" #include "help.h" -#ifdef _AUDIO +#ifdef AUDIO #include "audio_call.h" #endif @@ -46,8 +46,8 @@ extern char *DATA_FILE; extern char *BLOCK_FILE; extern ToxWindow *prompt; -extern struct _Winthread Winthread; -extern struct user_settings *user_settings_; +extern struct Winthread Winthread; +extern struct user_settings *user_settings; extern struct arg_opts arg_opts; static uint8_t blocklist_view = 0; /* 0 if we're in friendlist view, 1 if we're in blocklist view */ @@ -285,7 +285,7 @@ static void update_friend_last_online(int32_t num, uint64_t timestamp) Friends.list[num].last_online.tm = *localtime((const time_t*)×tamp); /* if the format changes make sure TIME_STR_SIZE is the correct size */ - const char *t = user_settings_->time == TIME_12 ? "%I:%M %p" : "%H:%M"; + const char *t = user_settings->time == TIME_12 ? "%I:%M %p" : "%H:%M"; strftime(Friends.list[num].last_online.hour_min_str, TIME_STR_SIZE, t, &Friends.list[num].last_online.tm); } @@ -377,7 +377,7 @@ void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int32_t num, bool sort) Friends.list[i].chatwin = -1; Friends.list[i].online = false; Friends.list[i].status = TOX_USERSTATUS_NONE; - Friends.list[i].logging_on = (bool) user_settings_->autolog == AUTOLOG_ON; + Friends.list[i].logging_on = (bool) user_settings->autolog == AUTOLOG_ON; tox_get_client_id(m, num, (uint8_t *) Friends.list[i].pub_key); update_friend_last_online(i, tox_get_last_online(m, i)); @@ -419,7 +419,7 @@ static void friendlist_add_blocked(Tox *m, int32_t fnum, int32_t bnum) Friends.list[i].active = true; Friends.list[i].chatwin = -1; Friends.list[i].status = TOX_USERSTATUS_NONE; - Friends.list[i].logging_on = (bool) user_settings_->autolog == AUTOLOG_ON; + Friends.list[i].logging_on = (bool) user_settings->autolog == AUTOLOG_ON; Friends.list[i].namelength = Blocked.list[bnum].namelength; update_friend_last_online(i, Blocked.list[bnum].last_on); memcpy(Friends.list[i].name, Blocked.list[bnum].name, Friends.list[i].namelength + 1); @@ -994,7 +994,7 @@ void disable_chatwin(int32_t f_num) Friends.list[f_num].chatwin = -1; } -#ifdef _AUDIO +#ifdef AUDIO static void friendlist_onAv(ToxWindow *self, ToxAv *av, int call_index) { int id = toxav_get_peer_id(av, call_index, 0); @@ -1021,7 +1021,7 @@ static void friendlist_onAv(ToxWindow *self, ToxAv *av, int call_index) } } } -#endif /* _AUDIO */ +#endif /* AUDIO */ ToxWindow new_friendlist(void) { @@ -1043,7 +1043,7 @@ ToxWindow new_friendlist(void) ret.onFileSendRequest = &friendlist_onFileSendRequest; ret.onGroupInvite = &friendlist_onGroupInvite; -#ifdef _AUDIO +#ifdef AUDIO ret.onInvite = &friendlist_onAv; ret.onRinging = &friendlist_onAv; ret.onStarting = &friendlist_onAv; @@ -1058,7 +1058,7 @@ ToxWindow new_friendlist(void) ret.call_idx = -1; ret.device_selection[0] = ret.device_selection[1] = -1; -#endif /* _AUDIO */ +#endif /* AUDIO */ ret.active_box = -1; diff --git a/src/friendlist.h b/src/friendlist.h index 6d0a705..2bee240 100644 --- a/src/friendlist.h +++ b/src/friendlist.h @@ -20,8 +20,8 @@ * */ -#ifndef FRIENDLIST_H_53I41IM -#define FRIENDLIST_H_53I41IM +#ifndef FRIENDLIST_H +#define FRIENDLIST_H #include @@ -95,4 +95,4 @@ void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int32_t num, bool sort); /* sorts friendlist_index first by connection status then alphabetically */ void sort_friendlist_index(void); -#endif /* end of include guard: FRIENDLIST_H_53I41IM */ +#endif /* end of include guard: FRIENDLIST_H */ diff --git a/src/global_commands.c b/src/global_commands.c index 18bdee1..0855ea1 100644 --- a/src/global_commands.c +++ b/src/global_commands.c @@ -70,7 +70,7 @@ void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[ on_friendadded(m, friendnum, true); } - memset(&FriendRequests.request[req], 0, sizeof(struct _friend_request)); + memset(&FriendRequests.request[req], 0, sizeof(struct friend_request)); int i; @@ -232,7 +232,7 @@ void cmd_decline(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv) return; } - memset(&FriendRequests.request[req], 0, sizeof(struct _friend_request)); + memset(&FriendRequests.request[req], 0, sizeof(struct friend_request)); int i; diff --git a/src/global_commands.h b/src/global_commands.h index 2d3b060..0597e19 100644 --- a/src/global_commands.h +++ b/src/global_commands.h @@ -20,8 +20,8 @@ * */ -#ifndef _global_commands_h -#define _global_commands_h +#ifndef GLOBAL_COMMANDS_H +#define GLOBAL_COMMANDS_H #include "windows.h" #include "toxic.h" @@ -43,9 +43,9 @@ void cmd_status(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZ void cmd_add_helper(ToxWindow *self, Tox *m, char *id_bin, char *msg); -#ifdef _AUDIO +#ifdef AUDIO void cmd_list_devices(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_change_device(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); -#endif /* _AUDIO */ +#endif /* AUDIO */ -#endif /* #define _global_commands_h */ +#endif /* #define GLOBAL_COMMANDS_H */ diff --git a/src/groupchat.c b/src/groupchat.c index b17c96a..134b6bd 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -50,7 +50,7 @@ extern char *DATA_FILE; static GroupChat groupchats[MAX_GROUPCHAT_NUM]; static int max_groupchat_index = 0; -extern struct user_settings *user_settings_; +extern struct user_settings *user_settings; /* temporary until group chats have unique commands */ extern const char glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE]; @@ -384,12 +384,12 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) } else { sound_notify(self, error, 0, NULL); } - } else if (key == user_settings_->key_peer_list_down) { /* Scroll peerlist up and down one position */ + } else if (key == user_settings->key_peer_list_down) { /* Scroll peerlist up and down one position */ int L = y2 - CHATBOX_HEIGHT - SDBAR_OFST; if (groupchats[self->num].side_pos < groupchats[self->num].num_peers - L) ++groupchats[self->num].side_pos; - } else if (key == user_settings_->key_peer_list_up) { + } else if (key == user_settings->key_peer_list_up) { if (groupchats[self->num].side_pos > 0) --groupchats[self->num].side_pos; } else if (key == '\n') { @@ -503,7 +503,7 @@ static void groupchat_onInit(ToxWindow *self, Tox *m) line_info_init(ctx->hst); - if (user_settings_->autolog == AUTOLOG_ON) { + if (user_settings->autolog == AUTOLOG_ON) { char myid[TOX_FRIEND_ADDRESS_SIZE]; tox_get_address(m, (uint8_t *) myid); log_enable(self->name, myid, NULL, ctx->log, LOG_GROUP); diff --git a/src/groupchat.h b/src/groupchat.h index 56f08b8..e76df10 100644 --- a/src/groupchat.h +++ b/src/groupchat.h @@ -20,8 +20,8 @@ * */ -#ifndef _groupchat_h -#define _groupchat_h +#ifndef GROUPCHAT_H +#define GROUPCHAT_H #include "toxic.h" #include "windows.h" @@ -45,4 +45,4 @@ void kill_groupchat_window(ToxWindow *self); int init_groupchat_win(ToxWindow *prompt, Tox *m, int groupnum); ToxWindow new_group_chat(Tox *m, int groupnum); -#endif /* #define _groupchat_h */ +#endif /* #define GROUPCHAT_H */ diff --git a/src/help.c b/src/help.c index 929a30c..d2ca337 100644 --- a/src/help.c +++ b/src/help.c @@ -151,14 +151,14 @@ static void help_draw_global(ToxWindow *self) wprintw(win, " /close : Close the current chat window\n"); wprintw(win, " /quit or /exit : Exit Toxic\n"); -#ifdef _AUDIO +#ifdef AUDIO wattron(win, A_BOLD); wprintw(win, "\n Audio:\n"); wattroff(win, A_BOLD); wprintw(win, " /lsdev : List devices where type: in|out\n"); wprintw(win, " /sdev : Set active device\n"); -#endif /* _AUDIO */ +#endif /* AUDIO */ help_draw_bottom_menu(win); @@ -182,7 +182,7 @@ static void help_draw_chat(ToxWindow *self) wprintw(win, " /savefile : Receive a file\n"); wprintw(win, " /cancel : Cancel file transfer where type: in|out\n"); -#ifdef _AUDIO +#ifdef AUDIO wattron(win, A_BOLD); wprintw(win, "\n Audio:\n"); wattroff(win, A_BOLD); @@ -194,7 +194,7 @@ static void help_draw_chat(ToxWindow *self) wprintw(win, " /sdev : Change active device\n"); wprintw(win, " /mute : Mute active device if in call\n"); wprintw(win, " /sense : VAD sensitivity treshold\n"); -#endif /* _AUDIO */ +#endif /* AUDIO */ help_draw_bottom_menu(win); @@ -256,7 +256,7 @@ void help_onKey(ToxWindow *self, wint_t key) break; case 'c': -#ifdef _AUDIO +#ifdef AUDIO help_init_window(self, 19, 80); #else help_init_window(self, 9, 80); @@ -265,7 +265,7 @@ void help_onKey(ToxWindow *self, wint_t key) break; case 'g': -#ifdef _AUDIO +#ifdef AUDIO help_init_window(self, 23, 80); #else help_init_window(self, 19, 80); diff --git a/src/help.h b/src/help.h index d46e703..e5680f2 100644 --- a/src/help.h +++ b/src/help.h @@ -20,8 +20,8 @@ * */ -#ifndef _help_h -#define _help_h +#ifndef HELP_H +#define HELP_H #include "toxic.h" #include "windows.h" @@ -39,4 +39,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 /* #define HELP_H */ diff --git a/src/input.h b/src/input.h index 1d4f40d..18d0fa6 100644 --- a/src/input.h +++ b/src/input.h @@ -20,8 +20,8 @@ * */ -#ifndef _input_h -#define _input_h +#ifndef INPUT_H +#define INPUT_H /* add a char to input field and buffer for given chatcontext */ void input_new_char(ToxWindow *self, wint_t key, int x, int y, int mx_x, int mx_y); @@ -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 */ \ No newline at end of file +#endif /* #define INPUT_H */ \ No newline at end of file diff --git a/src/line_info.c b/src/line_info.c index 740a090..1ea5dab 100644 --- a/src/line_info.c +++ b/src/line_info.c @@ -34,7 +34,7 @@ #include "message_queue.h" #include "misc_tools.h" -extern struct user_settings *user_settings_; +extern struct user_settings *user_settings; void line_info_init(struct history *hst) { @@ -226,7 +226,7 @@ static void line_info_check_queue(ToxWindow *self) if (line == NULL) return; - if (hst->start_id > user_settings_->history_size) + if (hst->start_id > user_settings->history_size) line_info_root_fwd(hst); line->id = hst->line_end->id + 1; @@ -494,19 +494,19 @@ bool line_info_onKey(ToxWindow *self, wint_t key) struct history *hst = self->chatwin->hst; bool match = true; - if (key == user_settings_->key_half_page_up) { + if (key == user_settings->key_half_page_up) { line_info_page_up(self, hst); } - else if (key == user_settings_->key_half_page_down) { + else if (key == user_settings->key_half_page_down) { line_info_page_down(self, hst); } - else if (key == user_settings_->key_scroll_line_up) { + else if (key == user_settings->key_scroll_line_up) { line_info_scroll_up(hst); } - else if (key == user_settings_->key_scroll_line_down) { + else if (key == user_settings->key_scroll_line_down) { line_info_scroll_down(hst); } - else if (key == user_settings_->key_page_bottom) { + else if (key == user_settings->key_page_bottom) { line_info_reset_start(self, hst); } else { diff --git a/src/line_info.h b/src/line_info.h index 784bdb5..1e0b66e 100644 --- a/src/line_info.h +++ b/src/line_info.h @@ -20,8 +20,8 @@ * */ -#ifndef _line_info_h -#define _line_info_h +#ifndef LINE_INFO_H +#define LINE_INFO_H #include "windows.h" #include "toxic.h" @@ -92,4 +92,4 @@ void line_info_set(ToxWindow *self, uint32_t id, char *msg); 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 /* #define LINE_INFO_H */ diff --git a/src/log.c b/src/log.c index 8d95a93..c133d72 100644 --- a/src/log.c +++ b/src/log.c @@ -33,7 +33,7 @@ #include "settings.h" #include "line_info.h" -extern struct user_settings *user_settings_; +extern struct user_settings *user_settings; /* Opens log file or creates a new one */ static int init_logging_session(char *name, const char *selfkey, const char *otherkey, struct chatlog *log, int logtype) @@ -45,7 +45,7 @@ static int init_logging_session(char *name, const char *selfkey, const char *oth name = UNKNOWN_NAME; const char *namedash = logtype == LOG_PROMPT ? "" : "-"; - const char *set_path = user_settings_->chatlogs_path; + const char *set_path = user_settings->chatlogs_path; char *user_config_dir = get_user_config_dir(); int path_len = strlen(name) + strlen(".log") + strlen("-") + strlen(namedash); @@ -118,7 +118,7 @@ void write_to_log(const char *msg, const char *name, struct chatlog *log, bool e else snprintf(name_frmt, sizeof(name_frmt), "%s:", name); - const char *t = user_settings_->time == TIME_12 ? "%Y/%m/%d [%I:%M:%S %p]" : "%Y/%m/%d [%H:%M:%S]"; + const char *t = user_settings->time == TIME_12 ? "%Y/%m/%d [%I:%M:%S %p]" : "%Y/%m/%d [%H:%M:%S]"; char s[MAX_STR_SIZE]; strftime(s, MAX_STR_SIZE, t, get_time()); fprintf(log->file, "%s %s %s\n", s, name_frmt, msg); @@ -181,7 +181,7 @@ void load_chat_history(ToxWindow *self, struct chatlog *log) } /* Number of history lines to load: must not be larger than MAX_LINE_INFO_QUEUE - 2 */ - int L = MIN(MAX_LINE_INFO_QUEUE - 2, user_settings_->history_size); + int L = MIN(MAX_LINE_INFO_QUEUE - 2, user_settings->history_size); int start, count = 0; /* start at end and backtrace L lines or to the beginning of buffer */ diff --git a/src/log.h b/src/log.h index d212b4c..0636836 100644 --- a/src/log.h +++ b/src/log.h @@ -20,8 +20,8 @@ * */ -#ifndef _log_h -#define _log_h +#ifndef LOG_H +#define LOG_H struct chatlog { FILE *file; @@ -48,4 +48,4 @@ void log_disable(struct chatlog *log); /* Loads previous history from chat log */ void load_chat_history(ToxWindow *self, struct chatlog *log); -#endif /* #define _log_h */ +#endif /* #define LOG_H */ diff --git a/src/message_queue.h b/src/message_queue.h index 3ceec47..b82cec3 100644 --- a/src/message_queue.h +++ b/src/message_queue.h @@ -20,6 +20,9 @@ * */ +#ifndef MESSAGE_QUEUE_H +#define MESSAGE_QUEUE_H + struct cqueue_msg { char message[MAX_STR_SIZE]; int len; @@ -44,3 +47,5 @@ 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 */ \ No newline at end of file diff --git a/src/misc_tools.c b/src/misc_tools.c index 0729eb7..8f01739 100644 --- a/src/misc_tools.c +++ b/src/misc_tools.c @@ -35,7 +35,7 @@ #include "file_senders.h" extern ToxWindow *prompt; -extern struct user_settings *user_settings_; +extern struct user_settings *user_settings; static uint64_t current_unix_time; @@ -82,12 +82,12 @@ struct tm *get_time(void) /*Puts the current time in buf in the format of [HH:mm:ss] */ void get_time_str(char *buf, int bufsize) { - if (user_settings_->timestamps == TIMESTAMPS_OFF) { + if (user_settings->timestamps == TIMESTAMPS_OFF) { buf[0] = '\0'; return; } - const char *t = user_settings_->time == TIME_12 ? "[%-I:%M:%S] " : "[%H:%M:%S] "; + const char *t = user_settings->time == TIME_12 ? "[%-I:%M:%S] " : "[%H:%M:%S] "; strftime(buf, bufsize, t, get_time()); } diff --git a/src/misc_tools.h b/src/misc_tools.h index 8d14b61..e4966d1 100644 --- a/src/misc_tools.h +++ b/src/misc_tools.h @@ -19,8 +19,8 @@ * along with Toxic. If not, see . * */ -#ifndef _misc_tools_h -#define _misc_tools_h +#ifndef MISC_TOOLS_H +#define MISC_TOOLS_H #include "windows.h" #include "toxic.h" @@ -112,4 +112,4 @@ void bytes_convert_str(char *buf, int size, uint64_t bytes); /* checks if a file exists. Returns true or false */ bool file_exists(const char *path); -#endif /* #define _misc_tools_h */ +#endif /* #define MISC_TOOLS_H */ diff --git a/src/notify.c b/src/notify.c index e8d96e3..9274186 100644 --- a/src/notify.c +++ b/src/notify.c @@ -36,7 +36,7 @@ #include #include -#if defined(_AUDIO) || defined(_SOUND_NOTIFY) +#if defined(AUDIO) || defined(SOUND_NOTIFY) #ifdef __APPLE__ #include #include @@ -48,16 +48,16 @@ #include #endif #endif - #ifdef _SOUND_NOTIFY + #ifdef SOUND_NOTIFY #include /* freealut packet */ #endif -#endif /* _AUDIO */ +#endif /* AUDIO */ -#ifdef _X11 +#ifdef X11 #include -#endif /* _X11 */ +#endif /* X11 */ -#ifdef _BOX_NOTIFY +#ifdef BOX_NOTIFY #include #endif @@ -65,36 +65,36 @@ #define SOUNDS_SIZE 10 #define ACTIVE_NOTIFS_MAX 50 -extern struct user_settings *user_settings_; +extern struct user_settings *user_settings; -struct _Control { +struct Control { time_t cooldown; time_t notif_timeout; -#ifdef _X11 +#ifdef X11 Display *display; unsigned long this_window; -#endif /* _X11 */ +#endif /* X11 */ -#if defined(_SOUND_NOTIFY) || defined(_BOX_NOTIFY) +#if defined(SOUND_NOTIFY) || defined(BOX_NOTIFY) pthread_mutex_t poll_mutex[1]; bool poll_active; #endif -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY uint32_t device_idx; /* index of output device */ char* sounds[SOUNDS_SIZE]; -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } Control = {0}; struct _ActiveNotifications { -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY uint32_t source; uint32_t buffer; bool looping; #endif bool active; int *id_indicator; -#ifdef _BOX_NOTIFY +#ifdef BOX_NOTIFY NotifyNotification* box; char messages[MAX_BOX_MSG_LEN + 1][MAX_BOX_MSG_LEN + 1]; char title[24]; @@ -122,7 +122,7 @@ static void tab_notify(ToxWindow *self, uint64_t flags) self->alert = WINDOW_ALERT_2; } -#ifdef _X11 +#ifdef X11 long unsigned int get_focused_window_id() { if (!Control.display) return 0; @@ -132,12 +132,12 @@ long unsigned int get_focused_window_id() XGetInputFocus(Control.display, &focus, &revert); return focus; } -#endif /* _X11 */ +#endif /* X11 */ static bool notifications_are_disabled(uint64_t flags) { bool res = flags & NT_RESTOL && Control.cooldown > get_unix_time(); -#ifdef _X11 +#ifdef X11 return res || (flags & NT_NOFOCUS && Control.this_window == get_focused_window_id()); #else return res; @@ -146,19 +146,19 @@ static bool notifications_are_disabled(uint64_t flags) static void control_lock() { -#if defined(_SOUND_NOTIFY) || defined(_BOX_NOTIFY) +#if defined(SOUND_NOTIFY) || defined(BOX_NOTIFY) pthread_mutex_lock(Control.poll_mutex); #endif } static void control_unlock() { -#if defined(_SOUND_NOTIFY) || defined(_BOX_NOTIFY) +#if defined(SOUND_NOTIFY) || defined(BOX_NOTIFY) pthread_mutex_unlock(Control.poll_mutex); #endif } -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY bool is_playing(int source) { int ready; @@ -174,7 +174,7 @@ void graceful_clear() while (1) { for (i = 0; i < ACTIVE_NOTIFS_MAX; i ++) { if (actives[i].active) { - #ifdef _BOX_NOTIFY + #ifdef BOX_NOTIFY if (actives[i].box) { GError* ignore; notify_notification_close(actives[i].box, &ignore); @@ -211,7 +211,7 @@ void* do_playing(void* _p) control_lock(); for (i = 0; i < ACTIVE_NOTIFS_MAX; i ++) { if (actives[i].active && !actives[i].looping - #ifdef _BOX_NOTIFY + #ifdef BOX_NOTIFY && !actives[i].box #endif ) { @@ -223,7 +223,7 @@ void* do_playing(void* _p) memset(&actives[i], 0, sizeof(struct _ActiveNotifications)); } } - #ifdef _BOX_NOTIFY + #ifdef BOX_NOTIFY else if (actives[i].box && time(NULL) >= actives[i].n_timeout) { GError* ignore; @@ -266,7 +266,7 @@ int play_source(uint32_t source, uint32_t buffer, bool looping) return i; } -#elif _BOX_NOTIFY +#elif BOX_NOTIFY void* do_playing(void* _p) { (void)_p; @@ -321,13 +321,13 @@ void graceful_clear() /* Opens primary device */ int init_notify(int login_cooldown, int notification_timeout) { -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY alutInitWithoutContext(NULL, NULL); if (open_primary_device(output, &Control.device_idx, 48000, 20, 1) != de_None) return -1; -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ -#if defined(_SOUND_NOTIFY) || defined(_BOX_NOTIFY) +#if defined(SOUND_NOTIFY) || defined(BOX_NOTIFY) pthread_mutex_init(Control.poll_mutex, NULL); pthread_t thread; if (pthread_create(&thread, NULL, do_playing, NULL) != 0 || pthread_detach(thread) != 0 ) { @@ -338,13 +338,13 @@ int init_notify(int login_cooldown, int notification_timeout) #endif Control.cooldown = time(NULL) + login_cooldown; -#ifdef _X11 +#ifdef X11 Control.display = XOpenDisplay(NULL); Control.this_window = get_focused_window_id(); -#endif /* _X11 */ +#endif /* X11 */ -#ifdef _BOX_NOTIFY +#ifdef BOX_NOTIFY notify_init("toxic"); #endif Control.notif_timeout = notification_timeout; @@ -353,26 +353,26 @@ int init_notify(int login_cooldown, int notification_timeout) void terminate_notify() { -#if defined(_SOUND_NOTIFY) || defined(_BOX_NOTIFY) +#if defined(SOUND_NOTIFY) || defined(BOX_NOTIFY) if ( !Control.poll_active ) return; Control.poll_active = 0; graceful_clear(); #endif -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY int i = 0; for (; i < SOUNDS_SIZE; i ++) free(Control.sounds[i]); close_device(output, Control.device_idx); alutExit(); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ -#ifdef _BOX_NOTIFY +#ifdef BOX_NOTIFY notify_uninit(); #endif } -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY int set_sound(Notification sound, const char* value) { if (sound == silent) return 0; @@ -428,7 +428,7 @@ int play_notify_sound(Notification notif, uint64_t flags) void stop_sound(int id) { if (id >= 0 && id < ACTIVE_NOTIFS_MAX && actives[id].looping && actives[id].active ) { -#ifdef _BOX_NOTIFY +#ifdef BOX_NOTIFY if (actives[id].box) { GError* ignore; notify_notification_close(actives[id].box, &ignore); @@ -446,17 +446,17 @@ void stop_sound(int id) static int m_play_sound(Notification notif, uint64_t flags) { -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY return play_notify_sound(notif, flags); #else if (notif != silent) beep(); return -1; -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } -#ifdef _BOX_NOTIFY +#ifdef BOX_NOTIFY void m_notify_action(NotifyNotification *box, char *action, void* data) { } @@ -472,13 +472,13 @@ int sound_notify(ToxWindow* self, Notification notif, uint64_t flags, int* id_in int id = -1; control_lock(); - if (self && (!self->stb || self->stb->status != TOX_USERSTATUS_BUSY) && user_settings_->alerts == ALERTS_ENABLED) + if (self && (!self->stb || self->stb->status != TOX_USERSTATUS_BUSY) && user_settings->alerts == ALERTS_ENABLED) id = m_play_sound(notif, flags); else if (flags & NT_ALWAYS) id = m_play_sound(notif, flags); -#if defined(_BOX_NOTIFY) && !defined(_SOUND_NOTIFY) +#if defined(BOX_NOTIFY) && !defined(SOUND_NOTIFY) if (id == -1) { for (id = 0; id < ACTIVE_NOTIFS_MAX && actives[id].box; id ++); @@ -508,7 +508,7 @@ int sound_notify2(ToxWindow* self, Notification notif, uint64_t flags, int id) return -1; if (id < 0 || id >= ACTIVE_NOTIFS_MAX) return -1; -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY control_lock(); if (!actives[id].active || !Control.sounds[notif]) { @@ -537,7 +537,7 @@ int sound_notify2(ToxWindow* self, Notification notif, uint64_t flags, int id) beep(); return 0; -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ } int box_notify(ToxWindow* self, Notification notif, uint64_t flags, int* id_indicator, char* title, const char* format, ...) @@ -547,13 +547,13 @@ int box_notify(ToxWindow* self, Notification notif, uint64_t flags, int* id_indi return -1; } -#ifdef _BOX_NOTIFY +#ifdef BOX_NOTIFY int id = sound_notify(self, notif, flags, id_indicator); control_lock(); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY if (id == -1) { /* Could not play */ for (id = 0; id < ACTIVE_NOTIFS_MAX && actives[id].active; id ++); @@ -601,7 +601,7 @@ int box_notify2(ToxWindow* self, Notification notif, uint64_t flags, int id, con return -1; } -#ifdef _BOX_NOTIFY +#ifdef BOX_NOTIFY if (sound_notify2(self, notif, flags, id) == -1) return -1; @@ -651,7 +651,7 @@ int box_silent_notify(ToxWindow* self, uint64_t flags, int* id_indicator, const if (notifications_are_disabled(flags)) return -1; -#ifdef _BOX_NOTIFY +#ifdef BOX_NOTIFY control_lock(); @@ -701,7 +701,7 @@ int box_silent_notify2(ToxWindow* self, uint64_t flags, int id, const char* form if (notifications_are_disabled(flags)) return -1; -#ifdef _BOX_NOTIFY +#ifdef BOX_NOTIFY control_lock(); if (id < 0 || id >= ACTIVE_NOTIFS_MAX || !actives[id].box || actives[id].size >= MAX_BOX_MSG_LEN + 1 ) { diff --git a/src/notify.h b/src/notify.h index ce0f8a6..d8a276c 100644 --- a/src/notify.h +++ b/src/notify.h @@ -20,8 +20,8 @@ * */ -#ifndef _notify_h -#define _notify_h +#ifndef NOTIFY_H +#define NOTIFY_H #include #include "windows.h" @@ -73,8 +73,8 @@ int box_notify2(ToxWindow* self, Notification notif, uint64_t flags, int id, con int box_silent_notify(ToxWindow* self, uint64_t flags, int* id_indicator, const char* title, const char* format, ...); int box_silent_notify2(ToxWindow* self, uint64_t flags, int id, const char* format, ...); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY int set_sound(Notification sound, const char* value); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ -#endif /* _notify_h */ +#endif /* NOTIFY_H */ diff --git a/src/prompt.c b/src/prompt.c index eb684a0..42f81ed 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -43,8 +43,8 @@ #include "autocomplete.h" extern ToxWindow *prompt; -extern struct user_settings *user_settings_; -extern struct _Winthread Winthread; +extern struct user_settings *user_settings; +extern struct Winthread Winthread; _FriendRequests FriendRequests; @@ -67,12 +67,12 @@ const char glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE] = { { "/requests" }, { "/status" }, -#ifdef _AUDIO +#ifdef AUDIO { "/lsdev" }, { "/sdev" }, -#endif /* _AUDIO */ +#endif /* AUDIO */ }; void kill_prompt_window(ToxWindow *self) @@ -455,7 +455,7 @@ static void prompt_onInit(ToxWindow *self, Tox *m) line_info_init(ctx->hst); - if (user_settings_->autolog == AUTOLOG_ON) { + if (user_settings->autolog == AUTOLOG_ON) { char myid[TOX_FRIEND_ADDRESS_SIZE]; tox_get_address(m, (uint8_t *) myid); log_enable(self->name, myid, NULL, ctx->log, LOG_PROMPT); @@ -464,7 +464,7 @@ static void prompt_onInit(ToxWindow *self, Tox *m) scrollok(ctx->history, 0); wmove(self->window, y2 - CURS_Y_OFFSET, 0); - if (user_settings_->show_welcome_msg == SHOW_WELCOME_MSG_ON) + if (user_settings->show_welcome_msg == SHOW_WELCOME_MSG_ON) print_welcome_msg(self); } diff --git a/src/prompt.h b/src/prompt.h index 9cf6d72..21563cb 100644 --- a/src/prompt.h +++ b/src/prompt.h @@ -20,21 +20,21 @@ * */ -#ifndef PROMPT_H_UZYGWFFL -#define PROMPT_H_UZYGWFFL +#ifndef PROMPT_H +#define PROMPT_H #include "toxic.h" #include "windows.h" -#ifdef _AUDIO +#ifdef AUDIO #define AC_NUM_GLOB_COMMANDS 18 #else #define AC_NUM_GLOB_COMMANDS 16 -#endif /* _AUDIO */ +#endif /* AUDIO */ #define MAX_FRIEND_REQUESTS 32 -struct _friend_request { +struct friend_request { bool active; char msg[MAX_STR_SIZE]; uint8_t key[TOX_CLIENT_ID_SIZE]; @@ -43,7 +43,7 @@ struct _friend_request { typedef struct { int max_idx; int num_requests; - struct _friend_request request[MAX_FRIEND_REQUESTS]; + struct friend_request request[MAX_FRIEND_REQUESTS]; } _FriendRequests; ToxWindow new_prompt(void); @@ -55,4 +55,4 @@ void prompt_update_status(ToxWindow *prompt, uint8_t status); void prompt_update_connectionstatus(ToxWindow *prompt, bool is_connected); void kill_prompt_window(ToxWindow *self); -#endif /* end of include guard: PROMPT_H_UZYGWFFL */ +#endif /* end of include guard: PROMPT_H */ diff --git a/src/settings.c b/src/settings.c index 362c1bb..1c6a362 100644 --- a/src/settings.c +++ b/src/settings.c @@ -31,9 +31,9 @@ #include "notify.h" #include "misc_tools.h" -#ifdef _AUDIO +#ifdef AUDIO #include "device.h" -#endif /* _AUDIO */ +#endif /* AUDIO */ #include "settings.h" #include "line_info.h" @@ -44,7 +44,7 @@ #define NO_SOUND "silent" -static struct _ui_strings { +static struct ui_strings { const char* self; const char* timestamps; const char* alerts; @@ -81,7 +81,7 @@ static void ui_defaults(struct user_settings* settings) settings->show_welcome_msg = SHOW_WELCOME_MSG_ON; } -static const struct _keys_strings { +static const struct keys_strings { const char* self; const char* next_tab; const char* prev_tab; @@ -119,7 +119,7 @@ static void key_defaults(struct user_settings* settings) settings->key_peer_list_down = T_KEY_C_RB; } -static const struct _tox_strings { +static const struct tox_strings { const char* self; const char* download_path; const char* chatlogs_path; @@ -135,8 +135,8 @@ static void tox_defaults(struct user_settings* settings) strcpy(settings->chatlogs_path, ""); } -#ifdef _AUDIO -static const struct _audio_strings { +#ifdef AUDIO +static const struct audio_strings { const char* self; const char* input_device; const char* output_device; @@ -156,8 +156,8 @@ static void audio_defaults(struct user_settings* settings) } #endif -#ifdef _SOUND_NOTIFY -static const struct _sound_strings { +#ifdef SOUND_NOTIFY +static const struct sound_strings { const char* self; const char* error; const char* self_log_in; @@ -212,7 +212,7 @@ int settings_load(struct user_settings *s, const char *patharg) tox_defaults(s); key_defaults(s); -#ifdef _AUDIO +#ifdef AUDIO audio_defaults(s); #endif @@ -296,7 +296,7 @@ int settings_load(struct user_settings *s, const char *patharg) if (config_setting_lookup_string(setting, key_strings.peer_list_down, &tmp)) s->key_peer_list_down = key_parse(&tmp); } -#ifdef _AUDIO +#ifdef AUDIO if ((setting = config_lookup(cfg, audio_strings.self)) != NULL) { config_setting_lookup_int(setting, audio_strings.input_device, &s->audio_in_dev); s->audio_in_dev = s->audio_in_dev < 0 || s->audio_in_dev > MAX_DEVICES ? 0 : s->audio_in_dev; @@ -308,7 +308,7 @@ int settings_load(struct user_settings *s, const char *patharg) } #endif -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY if ((setting = config_lookup(cfg, sound_strings.self)) != NULL) { if ( (config_setting_lookup_string(setting, sound_strings.error, &str) != CONFIG_TRUE) || !set_sound(error, str) ) { diff --git a/src/settings.h b/src/settings.h index 31b4448..feaf871 100644 --- a/src/settings.h +++ b/src/settings.h @@ -20,8 +20,8 @@ * */ -#ifndef _settings_h -#define _settings_h +#ifndef SETTINGS_H +#define SETTINGS_H #include @@ -49,7 +49,7 @@ struct user_settings { int key_page_bottom; int key_peer_list_up; int key_peer_list_down; -#ifdef _AUDIO +#ifdef AUDIO int audio_in_dev; int audio_out_dev; double VAD_treshold; @@ -82,4 +82,4 @@ enum { } settings_values; int settings_load(struct user_settings *s, const char *patharg); -#endif /* #define _settings_h */ +#endif /* #define SETTINGS_H */ diff --git a/src/toxic.c b/src/toxic.c index ecc4371..492ee19 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -57,17 +57,17 @@ #include "device.h" #include "message_queue.h" -#ifdef _AUDIO +#ifdef AUDIO #include "audio_call.h" -#endif /* _AUDIO */ +#endif /* AUDIO */ #ifndef PACKAGE_DATADIR #define PACKAGE_DATADIR "." #endif -#ifdef _AUDIO +#ifdef AUDIO ToxAv *av; -#endif /* _AUDIO */ +#endif /* AUDIO */ /* Export for use in Callbacks */ char *DATA_FILE = NULL; @@ -76,15 +76,15 @@ ToxWindow *prompt = NULL; #define AUTOSAVE_FREQ 60 -struct _Winthread Winthread; -struct _cqueue_thread cqueue_thread; +struct Winthread Winthread; +struct cqueue_thread cqueue_thread; struct arg_opts arg_opts; -struct user_settings *user_settings_ = NULL; +struct user_settings *user_settings = NULL; #define MIN_PASSWORD_LEN 6 #define MAX_PASSWORD_LEN 64 -static struct _user_password { +static struct user_password { bool data_is_encrypted; char pass[MAX_PASSWORD_LEN + 1]; int len; @@ -118,21 +118,21 @@ static void init_signal_catchers(void) void exit_toxic_success(Tox *m) { store_data(m, DATA_FILE); - memset(&user_password, 0, sizeof(struct _user_password)); + memset(&user_password, 0, sizeof(struct user_password)); close_all_file_senders(m); kill_all_windows(m); free(DATA_FILE); free(BLOCK_FILE); - free(user_settings_); + free(user_settings); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY // sound_notify(NULL, self_log_out, NT_ALWAYS, NULL); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ terminate_notify(); -#ifdef _AUDIO +#ifdef AUDIO terminate_audio(); -#endif /* _AUDIO */ +#endif /* AUDIO */ tox_kill(m); endwin(); exit(EXIT_SUCCESS); @@ -171,7 +171,7 @@ static void init_term(void) short bg_color = COLOR_BLACK; start_color(); - if (user_settings_->colour_theme == NATIVE_COLS) { + if (user_settings->colour_theme == NATIVE_COLS) { if (assume_default_colors(-1, -1) == OK) bg_color = -1; } @@ -324,7 +324,7 @@ static Tox *init_tox(void) #define MAXNODES 50 #define NODELEN (MAX_NODE_LINE - TOX_CLIENT_ID_SIZE - 7) -static struct _toxNodes { +static struct toxNodes { int lines; char nodes[MAXNODES][NODELEN]; uint16_t ports[MAXNODES]; @@ -990,13 +990,13 @@ int main(int argc, char *argv[]) } /* init user_settings struct and load settings from conf file */ - user_settings_ = calloc(1, sizeof(struct user_settings)); + user_settings = calloc(1, sizeof(struct user_settings)); - if (user_settings_ == NULL) + if (user_settings == NULL) exit_toxic_err("failed in main", FATALERR_MEMORY); const char *p = arg_opts.config_path[0] ? arg_opts.config_path : NULL; - int settings_err = settings_load(user_settings_, p); + int settings_err = settings_load(user_settings, p); Tox *m = init_tox(); @@ -1026,24 +1026,24 @@ int main(int argc, char *argv[]) if (pthread_create(&cqueue_thread.tid, NULL, thread_cqueue, (void *) m) != 0) exit_toxic_err("failed in main", FATALERR_THREAD_CREATE); -#ifdef _AUDIO +#ifdef AUDIO av = init_audio(prompt, m); - set_primary_device(input, user_settings_->audio_in_dev); - set_primary_device(output, user_settings_->audio_out_dev); + set_primary_device(input, user_settings->audio_in_dev); + set_primary_device(output, user_settings->audio_out_dev); -#elif _SOUND_NOTIFY +#elif SOUND_NOTIFY if ( init_devices() == de_InternalError ) queue_init_message("Failed to init audio devices"); -#endif /* _AUDIO */ +#endif /* AUDIO */ init_notify(60, 3000); -#ifdef _SOUND_NOTIFY +#ifdef SOUND_NOTIFY // sound_notify(prompt, self_log_in, 0, NULL); -#endif /* _SOUND_NOTIFY */ +#endif /* SOUND_NOTIFY */ const char *msg; diff --git a/src/toxic.h b/src/toxic.h index 3f86a2c..093aee0 100644 --- a/src/toxic.h +++ b/src/toxic.h @@ -20,8 +20,8 @@ * */ -#ifndef _toxic_h -#define _toxic_h +#ifndef TOXIC_H +#define TOXIC_H #ifndef TOXICVER #define TOXICVER "NOVER_" /* Use the -D flag to set this */ @@ -111,4 +111,4 @@ void on_file_data(Tox *m, int32_t friendnumber, uint8_t filenumber, const uint8_ void on_typing_change(Tox *m, int32_t friendnumber, uint8_t is_typing, void *userdata); void on_read_receipt(Tox *m, int32_t, uint32_t, void *userdata); -#endif /* #define _toxic_h */ +#endif /* #define TOXIC_H */ diff --git a/src/toxic_strings.h b/src/toxic_strings.h index fde51d7..91408a8 100644 --- a/src/toxic_strings.h +++ b/src/toxic_strings.h @@ -20,8 +20,8 @@ * */ -#ifndef _toxic_strings_h -#define _toxic_strings_h +#ifndef TOXIC_STRINGS_H +#define TOXIC_STRINGS_H #include "windows.h" @@ -61,4 +61,4 @@ void add_line_to_hist(ChatContext *ctx); resets line if at end of history */ void fetch_hist_item(ChatContext *ctx, int key_dir); -#endif /* #define _toxic_strings_h */ +#endif /* #define TOXIC_STRINGS_H */ diff --git a/src/windows.c b/src/windows.c index 9370090..85946a5 100644 --- a/src/windows.c +++ b/src/windows.c @@ -35,12 +35,12 @@ #include "settings.h" extern char *DATA_FILE; -extern struct _Winthread Winthread; +extern struct Winthread Winthread; static ToxWindow windows[MAX_WINDOWS_NUM]; static ToxWindow *active_window; extern ToxWindow *prompt; -extern struct user_settings *user_settings_; +extern struct user_settings *user_settings; static int num_active_windows; @@ -67,7 +67,7 @@ void on_connectionchange(Tox *m, int32_t friendnumber, uint8_t status, void *use void on_typing_change(Tox *m, int32_t friendnumber, uint8_t is_typing, void *userdata) { - if (user_settings_->show_typing_other == SHOW_TYPING_OFF) + if (user_settings->show_typing_other == SHOW_TYPING_OFF) return; int i; @@ -278,7 +278,7 @@ void set_next_window(int ch) ToxWindow *inf = active_window; while (true) { - if (ch == user_settings_->key_next_tab) { + if (ch == user_settings->key_next_tab) { if (++active_window > end) active_window = windows; } else if (--active_window < windows) @@ -366,12 +366,12 @@ void on_window_resize(void) w->stb->topline = subwin(w->window, 2, x2, 0, 0); } -#ifdef _AUDIO +#ifdef AUDIO if (w->chatwin->infobox.active) { delwin(w->chatwin->infobox.win); w->chatwin->infobox.win = newwin(INFOBOX_HEIGHT, INFOBOX_WIDTH + 1, 1, x2 - INFOBOX_WIDTH); } -#endif /* _AUDIO */ +#endif /* AUDIO */ scrollok(w->chatwin->history, 0); } @@ -462,7 +462,7 @@ void draw_active_window(Tox *m) ltr = isprint(ch); #endif /* HAVE_WIDECHAR */ - if (!ltr && (ch == user_settings_->key_next_tab || ch == user_settings_->key_prev_tab)) { + if (!ltr && (ch == user_settings->key_next_tab || ch == user_settings->key_prev_tab)) { set_next_window((int) ch); } else { pthread_mutex_lock(&Winthread.lock); diff --git a/src/windows.h b/src/windows.h index 1b53a01..70d22f3 100644 --- a/src/windows.h +++ b/src/windows.h @@ -20,8 +20,8 @@ * */ -#ifndef _windows_h -#define _windows_h +#ifndef WINDOWS_H +#define WINDOWS_H #include #include @@ -30,9 +30,9 @@ #include -#ifdef _AUDIO +#ifdef AUDIO #include -#endif /* _AUDIO */ +#endif /* AUDIO */ #include "toxic.h" @@ -65,14 +65,14 @@ typedef enum { Uncomment if necessary */ /* #define URXVT_FIX */ -struct _Winthread { +struct Winthread { pthread_t tid; pthread_mutex_t lock; volatile sig_atomic_t sig_exit_toxic; volatile sig_atomic_t flag_resize; }; -struct _cqueue_thread { +struct cqueue_thread { pthread_t tid; }; @@ -123,7 +123,7 @@ struct ToxWindow { void(*onTypingChange)(ToxWindow *, Tox *, int32_t, uint8_t); void(*onReadReceipt)(ToxWindow *, Tox *, int32_t, uint32_t); -#ifdef _AUDIO +#ifdef AUDIO void(*onInvite)(ToxWindow *, ToxAv *, int); void(*onRinging)(ToxWindow *, ToxAv *, int); @@ -142,7 +142,7 @@ struct ToxWindow { int device_selection[2]; /* -1 if not set, if set uses these selections instead of primary device */ int ringing_sound; -#endif /* _AUDIO */ +#endif /* AUDIO */ int active_box; /* For box notify */ @@ -176,7 +176,7 @@ struct StatusBar { bool is_online; }; -#ifdef _AUDIO +#ifdef AUDIO #define INFOBOX_HEIGHT 7 @@ -195,7 +195,7 @@ struct infobox { WINDOW *win; }; -#endif /* _AUDIO */ +#endif /* AUDIO */ #define MAX_LINE_HIST 128 @@ -217,7 +217,7 @@ struct ChatContext { struct chatlog *log; struct chat_queue *cqueue; -#ifdef _AUDIO +#ifdef AUDIO struct infobox infobox; #endif @@ -248,4 +248,4 @@ ToxWindow *get_window_ptr(int i); call at least once per second */ void refresh_inactive_windows(void); -#endif /* #define _windows_h */ +#endif /* #define WINDOWS_H */