diff --git a/apidocs/c/profapi.h b/apidocs/c/profapi.h index a4d8f5bb..ca7f1aa6 100644 --- a/apidocs/c/profapi.h +++ b/apidocs/c/profapi.h @@ -1,3 +1,11 @@ +/* + * profapi.h + * + * Copyright (C) 2016 - 2017 James Booth + * Copyright (C) 2021 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ /** @file C plugin API. */ @@ -12,13 +20,13 @@ List of all hooks which plugins may implement: {@link profhooks.h} typedef char* PROF_WIN_TAG; /** Type representing a function pointer to a command callback */ -typedef void(*CMD_CB)(char **args); +typedef void (*CMD_CB)(char** args); /** Type representing a function pointer to a timed callback */ -typedef void(*TIMED_CB)(void); +typedef void (*TIMED_CB)(void); /** Type representing a function pointer to a window callback */ -typedef void(*WINDOW_CB)(PROF_WIN_TAG win, char *line); +typedef void (*WINDOW_CB)(PROF_WIN_TAG win, char* line); /** Highlights the console window in the status bar. */ void prof_cons_alert(void); @@ -28,7 +36,7 @@ Show a message in the console window. @param message the message to print @return 1 on success, 0 on failure */ -int prof_cons_show(const char * const message); +int prof_cons_show(const char* const message); /** Show a message in the console, using the specified theme. @@ -39,14 +47,14 @@ Themes are specified in ~/.local/share/profanity/plugin_themes @param message the message to print @return 1 on success, 0 on failure */ -int prof_cons_show_themed(const char *const group, const char *const item, const char *const def, const char *const message); +int prof_cons_show_themed(const char* const group, const char* const item, const char* const def, const char* const message); /** Show a message indicating the command has been called incorrectly. @param cmd the command name with leading slash, e.g. "/say" @return 1 on success, 0 on failure */ -int prof_cons_bad_cmd_usage(const char *const cmd); +int prof_cons_bad_cmd_usage(const char* const cmd); /** Register a new command, with help information, and callback for command execution. @@ -60,9 +68,9 @@ Profanity will do some basic validation when the command is called using the arg @param examples example usages @param callback The {@link CMD_CB} function to execute when the command is invoked */ -void prof_register_command(const char *command_name, int min_args, int max_args, - char **synopsis, const char *description, char *arguments[][2], char **examples, - CMD_CB callback); +void prof_register_command(const char* command_name, int min_args, int max_args, + char** synopsis, const char* description, char* arguments[][2], char** examples, + CMD_CB callback); /** Register a function that Profanity will call periodically. @@ -76,7 +84,7 @@ Add values to be autocompleted by Profanity for a command, or command argument. @param key the prefix to trigger autocompletion @param items the items to return on autocompletion */ -void prof_completer_add(const char *key, char **items); +void prof_completer_add(const char* key, char** items); /** Remove values from autocompletion for a command, or command argument. @@ -84,21 +92,21 @@ Remove values from autocompletion for a command, or command argument. @param key the prefix from which to remove the autocompletion items @param items the items to remove */ -void prof_completer_remove(const char *key, char **items); +void prof_completer_remove(const char* key, char** items); /** Remove all values from autocompletion for a command, or command argument. @param key the prefix from which to clear the autocompletion items */ -void prof_completer_clear(const char *key); +void prof_completer_clear(const char* key); /** Add filepath autocompletion for a command, or command argument. @param prefix the prefix from which filepath autocompletion will be triggered */ -void prof_filepath_completer_add(const char *prefix); +void prof_filepath_completer_add(const char* prefix); /** Send a desktop notification. @@ -106,13 +114,13 @@ Send a desktop notification. @param timeout_ms the length of time before the notification disappears in milliseconds @param category the category of the notification, also displayed */ -void prof_notify(const char *message, int timeout_ms, const char *category); +void prof_notify(const char* message, int timeout_ms, const char* category); /** Send a line of input to Profanity to execute. @param line the line to send */ -void prof_send_line(char *line); +void prof_send_line(char* line); /** Retrieve the Jabber ID of the current chat recipient, when in a chat window. @@ -142,13 +150,13 @@ char* prof_get_current_nick(void); Retrieve the nickname for a given barejid if it is in the roster. @return the users nickname e.g. "eddie", or the input barejid if it is not in the roster. */ -char* prof_get_name_from_roster(const char *barejid); +char* prof_get_name_from_roster(const char* barejid); /** Retrieve the barejid for a given nickname if it is in the roster. @return the users barejid e.g. "eddie@server.tld", or NULL if the nickname is not in the roster. */ -char* prof_get_barejid_from_roster(const char *name); +char* prof_get_barejid_from_roster(const char* name); /** Retrieve nicknames of all occupants in a chat room, when in a chat room window. @@ -161,31 +169,31 @@ Retrieve current nickname used in chat room. @param barejid The room's Jabber ID @return Room nickname. */ -char* prof_get_room_nick(const char *barejid); +char* prof_get_room_nick(const char* barejid); /** Write to the Profanity log at level DEBUG. @param message The message to log */ -void prof_log_debug(const char *message); +void prof_log_debug(const char* message); /** Write to the Profanity log at level INFO. @param message The message to log */ -void prof_log_info(const char *message); +void prof_log_info(const char* message); /** Write to the Profanity log at level WARNING. @param message The message to log */ -void prof_log_warning(const char *message); +void prof_log_warning(const char* message); /** Write to the Profanity log at level ERROR. @param message The message to log */ -void prof_log_error(const char *message); +void prof_log_error(const char* message); /** Create a plugin window. @@ -214,7 +222,7 @@ Show a message in the plugin window. @param message The message to print @return 1 on success, 0 on failure */ -int prof_win_show(PROF_WIN_TAG win, char *message); +int prof_win_show(PROF_WIN_TAG win, char* message); /** Show a message in the plugin window, using the specified theme. @@ -226,14 +234,14 @@ Themes are specified in ~/.local/share/profanity/plugin_themes @param message the message to print @return 1 on success, 0 on failure */ -int prof_win_show_themed(PROF_WIN_TAG tag, char *group, char *key, char *def, char *message); +int prof_win_show_themed(PROF_WIN_TAG tag, char* group, char* key, char* def, char* message); /** Send an XMPP stanza @param stanza an XMPP stanza @return 1 if the stanza was sent successfully, 0 otherwise */ -int prof_send_stanza(char *stanza); +int prof_send_stanza(char* stanza); /** Get a boolean setting @@ -243,7 +251,7 @@ Settings must be specified in ~/.local/share/profanity/plugin_settings @param def default value if setting not found @return the setting, or default value */ -int prof_settings_boolean_get(char *group, char *key, int def); +int prof_settings_boolean_get(char* group, char* key, int def); /** Set a boolean setting @@ -252,7 +260,7 @@ Settings must be specified in ~/.local/share/profanity/plugin_settings @param key the item name within the group @param value value to set */ -void prof_settings_boolean_set(char *group, char *key, int value); +void prof_settings_boolean_set(char* group, char* key, int value); /** Get a string setting @@ -262,7 +270,7 @@ Settings must be specified in ~/.local/share/profanity/plugin_settings @param def default value if setting not found @return the setting, or default value */ -char* prof_settings_string_get(char *group, char *key, char *def); +char* prof_settings_string_get(char* group, char* key, char* def); /** Set a string setting @@ -271,7 +279,7 @@ Settings must be specified in ~/.local/share/profanity/plugin_settings @param key the item name within the group @param value value to set */ -void prof_settings_string_set(char *group, char *key, char *value); +void prof_settings_string_set(char* group, char* key, char* value); /** Get a string list setting @@ -281,7 +289,7 @@ The string list setting items are separated by semicolons. @param key the item name within the group @return the list setting */ -char** prof_settings_string_list_get(char *group, char *key); +char** prof_settings_string_list_get(char* group, char* key); /** Add an item to a string list setting @@ -291,7 +299,7 @@ If the list does not exist, a new one will be created with the element added @param key the item name within the group @param value item to add */ -void prof_settings_string_list_add(char *group, char *key, char *value); +void prof_settings_string_list_add(char* group, char* key, char* value); /** Remove an item from a string list setting @@ -301,7 +309,7 @@ Settings must be specified in ~/.local/share/profanity/plugin_settings @param value item to remove @return 1 if the item was removed, or is not in the list, 0 if the list does not exist */ -int prof_settings_string_list_remove(char *group, char *key, char *value); +int prof_settings_string_list_remove(char* group, char* key, char* value); /** Remove all items from a string list setting @@ -310,7 +318,7 @@ Settings must be specified in ~/.local/share/profanity/plugin_settings @param key the item name within the group @return 1 if the list was cleared, 0 if the list does not exist */ -int prof_settings_string_list_clear(char *group, char *key); +int prof_settings_string_list_clear(char* group, char* key); /** Get an integer setting @@ -320,7 +328,7 @@ Settings must be specified in ~/.local/share/profanity/plugin_settings @param def default value if setting not found @return the setting, or default value */ -int prof_settings_int_get(char *group, char *key, int def); +int prof_settings_int_get(char* group, char* key, int def); /** Set an integer setting @@ -329,7 +337,7 @@ Settings must be specified in ~/.local/share/profanity/plugin_settings @param key the item name within the group @param value value to set */ -void prof_settings_int_set(char *group, char *key, int value); +void prof_settings_int_set(char* group, char* key, int value); /** Trigger incoming message handling, this plugin will make profanity act as if the message has been received @@ -337,20 +345,20 @@ Trigger incoming message handling, this plugin will make profanity act as if the @param resource resource of the sender of the message @param message the message text */ -void prof_incoming_message(char *barejid, char *resource, char *message); +void prof_incoming_message(char* barejid, char* resource, char* message); /** Add a service discovery feature the list supported by Profanity. If a session is already connected, a presence update will be sent to allow any client/server caches to update their feature list for Profanity @param feature the service discovery feature to be added */ -void prof_disco_add_feature(char *feature); +void prof_disco_add_feature(char* feature); /** End any encrypted session with the specified user. @param barejid Jabber ID of the recipient */ -void prof_encryption_reset(char *barejid); +void prof_encryption_reset(char* barejid); /** Set the text to display in the titlebar encryption indicator for recipient. @@ -358,14 +366,14 @@ Set the text to display in the titlebar encryption indicator for recipient. @param enctext The text to display @return 1 on success, 0 on failure */ -int prof_chat_set_titlebar_enctext(char *barejid, char *enctext); +int prof_chat_set_titlebar_enctext(char* barejid, char* enctext); /** Let profanity decide what to show in the titlebar encryption indicator for recipient. @param barejid Jabber ID of the recipient @return 1 on success, 0 on failure */ -int prof_chat_unset_titlebar_enctext(char *barejid); +int prof_chat_unset_titlebar_enctext(char* barejid); /** Set the incoming message prefix character for specified contact. @@ -373,14 +381,14 @@ Set the incoming message prefix character for specified contact. @param ch The character to display @return 1 on success, 0 on failure */ -int prof_chat_set_incoming_char(char *barejid, char *ch); +int prof_chat_set_incoming_char(char* barejid, char* ch); /** Reset the incoming message prefix character for specified contact. @param barejid Jabber ID of the recipient @return 1 on success, 0 on failure */ -int prof_chat_unset_incoming_char(char *barejid); +int prof_chat_unset_incoming_char(char* barejid); /** Set the outgoing message prefix character for specified contact. @@ -388,14 +396,14 @@ Set the outgoing message prefix character for specified contact. @param ch The character to display @return 1 on success, 0 on failure */ -int prof_chat_set_outgoing_char(char *barejid, char *ch); +int prof_chat_set_outgoing_char(char* barejid, char* ch); /** Reset the outgoing message prefix character for specified contact. @param barejid Jabber ID of the recipient @return 1 on success, 0 on failure */ -int prof_chat_unset_outgoing_char(char *barejid); +int prof_chat_unset_outgoing_char(char* barejid); /** Set the text to display in the titlebar encryption indicator for room. @@ -403,14 +411,14 @@ Set the text to display in the titlebar encryption indicator for room. @param enctext The text to display @return 1 on success, 0 on failure */ -int prof_room_set_titlebar_enctext(char *roomjid, char *enctext); +int prof_room_set_titlebar_enctext(char* roomjid, char* enctext); /** Let profanity decide what to show in the titlebar encryption indicator for room. @param roomjid Jabber ID of the room @return 1 on success, 0 on failure */ -int prof_room_unset_titlebar_enctext(char *roomjid); +int prof_room_unset_titlebar_enctext(char* roomjid); /** Set the message prefix character for specified room. @@ -418,14 +426,14 @@ Set the message prefix character for specified room. @param ch The character to display @return 1 on success, 0 on failure */ -int prof_room_set_message_char(char *roomjid, char *ch); +int prof_room_set_message_char(char* roomjid, char* ch); /** Reset the message prefix character for specified room. @param roomjid Jabber ID of the room @return 1 on success, 0 on failure */ -int prof_room_unset_message_char(char *roomjid); +int prof_room_unset_message_char(char* roomjid); /** Show a message in a chat window. @@ -433,7 +441,7 @@ Show a message in a chat window. @param message the message to print @return 1 on success, 0 on failure */ -int prof_chat_show(char *barejid, char *message); +int prof_chat_show(char* barejid, char* message); /** Show a message in a chat window, using the specified theme, and prefix character @@ -446,7 +454,7 @@ Themes are specified in ~/.local/share/profanity/plugin_themes @param message the message to print @return 1 on success, 0 on failure */ -int prof_chat_show_themed(char *barejid, char *group, char *item, char *def, char *ch, char *message); +int prof_chat_show_themed(char* barejid, char* group, char* item, char* def, char* ch, char* message); /** Show a message in a chat room window. @@ -454,7 +462,7 @@ Show a message in a chat room window. @param message the message to print @return 1 on success, 0 on failure */ -int prof_room_show(char *roomjid, char *message); +int prof_room_show(char* roomjid, char* message); /** Show a message in a chat room window, using the specified theme, and prefix character @@ -467,4 +475,4 @@ Themes are specified in ~/.local/share/profanity/plugin_themes @param message the message to print @return 1 on success, 0 on failure */ -int prof_room_show_themed(char *roomjid, char *group, char *item, char *def, char *ch, char *message); +int prof_room_show_themed(char* roomjid, char* group, char* item, char* def, char* ch, char* message); diff --git a/apidocs/c/profhooks.h b/apidocs/c/profhooks.h index c789454d..185e9dc4 100644 --- a/apidocs/c/profhooks.h +++ b/apidocs/c/profhooks.h @@ -1,3 +1,11 @@ +/* + * profhooks.h + * + * Copyright (C) 2016 - 2017 James Booth + * Copyright (C) 2021 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ /** @file C Hooks. */ @@ -9,7 +17,7 @@ Called when a plugin is loaded, either when profanity is started, or when the /p @param account_name account name of the currently logged in account, or NULL if not logged in @param fulljid the users full Jabber ID (barejid and resource) if logged in, NULL otherwise */ -void prof_init(const char * const version, const char * const status, const char *const account_name, const char *const fulljid); +void prof_init(const char* const version, const char* const status, const char* const account_name, const char* const fulljid); /** Called when Profanity is started @@ -31,14 +39,14 @@ Called when the user connects with an account @param account_name account name of the account used for logging in @param fulljid the full Jabber ID (barejid and resource) of the account */ -void prof_on_connect(const char * const account_name, const char * const fulljid); +void prof_on_connect(const char* const account_name, const char* const fulljid); /** Called when the user disconnects an account @param account_name account name of the account being disconnected @param fulljid the full Jabber ID (barejid and resource) of the account */ -void prof_on_disconnect(const char * const account_name, const char * const fulljid); +void prof_on_disconnect(const char* const account_name, const char* const fulljid); /** Called before a chat message is displayed @@ -47,7 +55,7 @@ Called before a chat message is displayed @param message the received message @return the new message to display, or NULL to preserve the original message */ -char* prof_pre_chat_message_display(const char * const barejid, const char *const resource, const char *message); +char* prof_pre_chat_message_display(const char* const barejid, const char* const resource, const char* message); /** Called after a chat message is displayed @@ -55,7 +63,7 @@ Called after a chat message is displayed @param resource resource of the message sender @param message the received message */ -void prof_post_chat_message_display(const char * const barejid, const char *const resource, const char *message); +void prof_post_chat_message_display(const char* const barejid, const char* const resource, const char* message); /** Called before a chat message is sent @@ -63,14 +71,14 @@ Called before a chat message is sent @param message the message to be sent @return the modified or original message to send, or NULL to cancel sending of the message */ -char* prof_pre_chat_message_send(const char * const barejid, const char *message); +char* prof_pre_chat_message_send(const char* const barejid, const char* message); /** Called after a chat message has been sent @param barejid Jabber ID of the message recipient @param message the sent message */ -void prof_post_chat_message_send(const char * const barejid, const char *message); +void prof_post_chat_message_send(const char* const barejid, const char* message); /** Called before a chat room message is displayed @@ -79,7 +87,7 @@ Called before a chat room message is displayed @param message the received message @return the new message to display, or NULL to preserve the original message */ -char* prof_pre_room_message_display(const char * const barejid, const char * const nick, const char *message); +char* prof_pre_room_message_display(const char* const barejid, const char* const nick, const char* message); /** Called after a chat room message is displayed @@ -87,7 +95,7 @@ Called after a chat room message is displayed @param nick nickname of the message sender @param message the received message */ -void prof_post_room_message_display(const char * const barejid, const char * const nick, const char *message); +void prof_post_room_message_display(const char* const barejid, const char* const nick, const char* message); /** Called before a chat room message is sent @@ -95,14 +103,14 @@ Called before a chat room message is sent @param message the message to be sent @return the modified or original message to send, or NULL to cancel sending of the message */ -char* prof_pre_room_message_send(const char * const barejid, const char *message); +char* prof_pre_room_message_send(const char* const barejid, const char* message); /** Called after a chat room message has been sent @param barejid Jabber ID of the room @param message the sent message */ -void prof_post_room_message_send(const char * const barejid, const char *message); +void prof_post_room_message_send(const char* const barejid, const char* message); /** Called when the server sends a chat room history message @@ -111,7 +119,7 @@ Called when the server sends a chat room history message @param message the message to be sent @param timestamp time the message was originally sent to the room, in ISO8601 format */ -void prof_on_room_history_message(const char * const barejid, const char *const nick, const char *const message, const char *const timestamp); +void prof_on_room_history_message(const char* const barejid, const char* const nick, const char* const message, const char* const timestamp); /** Called before a private chat room message is displayed @@ -120,7 +128,7 @@ Called before a private chat room message is displayed @param message the received message @return the new message to display, or NULL to preserve the original message */ -char* prof_pre_priv_message_display(const char * const barejid, const char * const nick, const char *message); +char* prof_pre_priv_message_display(const char* const barejid, const char* const nick, const char* message); /** Called after a private chat room message is displayed @@ -128,7 +136,7 @@ Called after a private chat room message is displayed @param nick nickname of the message sender @param message the received message */ -void prof_post_priv_message_display(const char * const barejid, const char * const nick, const char *message); +void prof_post_priv_message_display(const char* const barejid, const char* const nick, const char* message); /** Called before a private chat room message is sent @@ -137,7 +145,7 @@ Called before a private chat room message is sent @param message the message to be sent @return the modified or original message to send, or NULL to cancel sending of the message */ -char* prof_pre_priv_message_send(const char * const barejid, const char * const nick, const char *message); +char* prof_pre_priv_message_send(const char* const barejid, const char* const nick, const char* message); /** Called after a private chat room message has been sent @@ -145,49 +153,49 @@ Called after a private chat room message has been sent @param nick nickname of the message recipient @param message the sent message */ -void prof_post_priv_message_send(const char * const barejid, const char * const nick, const char *message); +void prof_post_priv_message_send(const char* const barejid, const char* const nick, const char* message); /** Called before an XMPP message stanza is sent @param stanza The stanza to send @return The new stanza to send, or NULL to preserve the original stanza */ -char* prof_on_message_stanza_send(const char *const stanza); +char* prof_on_message_stanza_send(const char* const stanza); /** Called when an XMPP message stanza is received @param stanza The stanza received @return 1 if Profanity should continue to process the message stanza, 0 otherwise */ -int prof_on_message_stanza_receive(const char *const stanza); +int prof_on_message_stanza_receive(const char* const stanza); /** Called before an XMPP presence stanza is sent @param stanza The stanza to send @return The new stanza to send, or NULL to preserve the original stanza */ -char* prof_on_presence_stanza_send(const char *const stanza); +char* prof_on_presence_stanza_send(const char* const stanza); /** Called when an XMPP presence stanza is received @param stanza The stanza received @return 1 if Profanity should continue to process the presence stanza, 0 otherwise */ -int prof_on_presence_stanza_receive(const char *const stanza); +int prof_on_presence_stanza_receive(const char* const stanza); /** Called before an XMPP iq stanza is sent @param stanza The stanza to send @return The new stanza to send, or NULL to preserve the original stanza */ -char* prof_on_iq_stanza_send(const char *const stanza); +char* prof_on_iq_stanza_send(const char* const stanza); /** Called when an XMPP iq stanza is received @param stanza The stanza received @return 1 if Profanity should continue to process the iq stanza, 0 otherwise */ -int prof_on_iq_stanza_receive(const char *const stanza); +int prof_on_iq_stanza_receive(const char* const stanza); /** Called when a contact goes offline @@ -195,7 +203,7 @@ Called when a contact goes offline @param resource the resource being disconnected @param status the status message received with the offline presence, or NULL */ -void prof_on_contact_offline(const char *const barejid, const char *const resource, const char *const status); +void prof_on_contact_offline(const char* const barejid, const char* const resource, const char* const status); /** Called when a presence notification is received from a contact @@ -205,16 +213,16 @@ Called when a presence notification is received from a contact @param status the status message received with the presence, or NULL @param priority the priority associated with the resource */ -void prof_on_contact_presence(const char *const barejid, const char *const resource, const char *const presence, const char *const status, const int priority); +void prof_on_contact_presence(const char* const barejid, const char* const resource, const char* const presence, const char* const status, const int priority); /** Called when a chat window is focused @param barejid Jabber ID of the chat window recipient */ -void prof_on_chat_win_focus(const char *const barejid); +void prof_on_chat_win_focus(const char* const barejid); /** Called when a chat room window is focused @param barejid Jabber ID of the room */ -void prof_on_room_win_focus(const char *const barejid); +void prof_on_room_win_focus(const char* const barejid); diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c index 10e89521..239937c0 100644 --- a/tests/functionaltests/functionaltests.c +++ b/tests/functionaltests/functionaltests.c @@ -1,3 +1,11 @@ +/* + * functionaltests.c + * + * Copyright (C) 2015 - 2018 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include #include diff --git a/tests/functionaltests/proftest.c b/tests/functionaltests/proftest.c index 8c655977..d91c2251 100644 --- a/tests/functionaltests/proftest.c +++ b/tests/functionaltests/proftest.c @@ -1,3 +1,11 @@ +/* + * proftest.c + * + * Copyright (C) 2015 - 2016 James Booth + * Copyright (C) 2019 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include #include @@ -56,8 +64,8 @@ prof_expect(int fd, ...) pfd.fd = fd; pfd.events = POLLIN; - GError *error = NULL; - GRegex *ansi = g_regex_new("\\x1b\\[[0-9;]*[a-zA-Z]|\\x1b\\([a-zA-Z]", 0, 0, &error); + GError* error = NULL; + GRegex* ansi = g_regex_new("\\x1b\\[[0-9;]*[a-zA-Z]|\\x1b\\([a-zA-Z]", 0, 0, &error); if (error) { g_error_free(error); return 0; @@ -70,7 +78,7 @@ prof_expect(int fd, ...) if (type == prof_expect_exact) { gchar* escaped = g_regex_escape_string(pattern, -1); error = NULL; - GRegex *regex = g_regex_new(escaped, G_REGEX_DOTALL | G_REGEX_OPTIMIZE, 0, &error); + GRegex* regex = g_regex_new(escaped, G_REGEX_DOTALL | G_REGEX_OPTIMIZE, 0, &error); if (error) { g_error_free(error); g_free(escaped); @@ -80,10 +88,10 @@ prof_expect(int fd, ...) return 0; } g_free(escaped); - GMatchInfo *match_info; + GMatchInfo* match_info; if (g_regex_match(regex, clean_output, 0, &match_info)) { - g_string_truncate(accumulated_output, 0); - + g_string_truncate(accumulated_output, 0); + g_match_info_free(match_info); g_regex_unref(regex); g_free(clean_output); @@ -94,9 +102,9 @@ prof_expect(int fd, ...) g_match_info_free(match_info); g_regex_unref(regex); } else if (type == prof_expect_regexp) { - GMatchInfo *match_info; + GMatchInfo* match_info; error = NULL; - GRegex *regex = g_regex_new(pattern, G_REGEX_DOTALL | G_REGEX_OPTIMIZE, 0, &error); + GRegex* regex = g_regex_new(pattern, G_REGEX_DOTALL | G_REGEX_OPTIMIZE, 0, &error); if (error) { g_error_free(error); g_free(clean_output); @@ -107,9 +115,9 @@ prof_expect(int fd, ...) if (g_regex_match(regex, clean_output, 0, &match_info)) { gint start_pos, end_pos; g_match_info_fetch_pos(match_info, 0, &start_pos, &end_pos); - + g_string_truncate(accumulated_output, 0); - + g_match_info_free(match_info); g_regex_unref(regex); g_free(clean_output); @@ -120,7 +128,7 @@ prof_expect(int fd, ...) g_match_info_free(match_info); g_regex_unref(regex); } - + g_free(clean_output); int ret = poll(&pfd, 1, 10); // 10ms timeout for poll @@ -253,7 +261,7 @@ prof_start(void) pid_t pid = forkpty(&master, NULL, NULL, NULL); if (pid == 0) { system("stty sane -echo"); - execlp("sh", "sh", "-c", "./tests/functionaltests/start_profanity.sh", (char *)0); + execlp("sh", "sh", "-c", "./tests/functionaltests/start_profanity.sh", (char*)0); _exit(1); } prof_pid = pid; @@ -263,8 +271,8 @@ prof_start(void) int init_prof_test(void** state) { - const char *cfg = getenv("XDG_CONFIG_HOME"); - const char *dat = getenv("XDG_DATA_HOME"); + const char* cfg = getenv("XDG_CONFIG_HOME"); + const char* dat = getenv("XDG_DATA_HOME"); config_orig = cfg ? g_strdup(cfg) : NULL; data_orig = dat ? g_strdup(dat) : NULL; @@ -272,7 +280,7 @@ init_prof_test(void** state) setenv("XDG_DATA_HOME", XDG_DATA_HOME, 1); usleep(1000 * 2000); // 2s delay between tests to let OS recover - + int res = -1; int port = 0; for (int i = 0; i < 5; i++) { @@ -337,7 +345,7 @@ int close_prof_test(void** state) { prof_input("/quit"); - + // Give it some time to quit gracefully int retries = 0; int status; @@ -445,7 +453,7 @@ prof_connect_with_roster(const char* roster) assert_true(prof_output_regex("successfully")); prof_expect_timeout = 10; stbbr_wait_for("presence:*"); - //usleep(1000 * 2000); // 2s delay + // usleep(1000 * 2000); // 2s delay } void diff --git a/tests/functionaltests/proftest.h b/tests/functionaltests/proftest.h index 99bf89c4..85b62f7b 100644 --- a/tests/functionaltests/proftest.h +++ b/tests/functionaltests/proftest.h @@ -1,3 +1,11 @@ +/* + * proftest.h + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2020 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #ifndef __H_PROFTEST #define __H_PROFTEST diff --git a/tests/functionaltests/test_carbons.c b/tests/functionaltests/test_carbons.c index aa827212..6c223ed6 100644 --- a/tests/functionaltests/test_carbons.c +++ b/tests/functionaltests/test_carbons.c @@ -1,3 +1,11 @@ +/* + * test_carbons.c + * + * Copyright (C) 2015 - 2017 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/functionaltests/test_carbons.h b/tests/functionaltests/test_carbons.h index 1096bb84..084cebc8 100644 --- a/tests/functionaltests/test_carbons.h +++ b/tests/functionaltests/test_carbons.h @@ -1,3 +1,11 @@ +/* + * test_carbons.h + * + * Copyright (C) 2015 - 2016 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void send_enable_carbons(void** state); void connect_with_carbons_enabled(void** state); void send_disable_carbons(void** state); diff --git a/tests/functionaltests/test_chat_session.c b/tests/functionaltests/test_chat_session.c index 751c9d00..701851f0 100644 --- a/tests/functionaltests/test_chat_session.c +++ b/tests/functionaltests/test_chat_session.c @@ -1,3 +1,11 @@ +/* + * test_chat_session.c + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/functionaltests/test_chat_session.h b/tests/functionaltests/test_chat_session.h index 3bd62fbc..d13b5276 100644 --- a/tests/functionaltests/test_chat_session.h +++ b/tests/functionaltests/test_chat_session.h @@ -1,3 +1,11 @@ +/* + * test_chat_session.h + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void sends_message_to_barejid_when_contact_offline(void** state); void sends_message_to_barejid_when_contact_online(void** state); void sends_message_to_fulljid_when_received_from_fulljid(void** state); diff --git a/tests/functionaltests/test_connect.c b/tests/functionaltests/test_connect.c index d2f55ec1..504a43e0 100644 --- a/tests/functionaltests/test_connect.c +++ b/tests/functionaltests/test_connect.c @@ -1,3 +1,11 @@ +/* + * test_connect.c + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2019 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/functionaltests/test_connect.h b/tests/functionaltests/test_connect.h index 889ea7c0..8e363cdd 100644 --- a/tests/functionaltests/test_connect.h +++ b/tests/functionaltests/test_connect.h @@ -1,3 +1,11 @@ +/* + * test_connect.h + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void connect_jid_requests_roster(void** state); void connect_jid_sends_presence_after_receiving_roster(void** state); void connect_jid_requests_bookmarks(void** state); diff --git a/tests/functionaltests/test_disconnect.c b/tests/functionaltests/test_disconnect.c index d7a8dfa3..6aed7aa3 100644 --- a/tests/functionaltests/test_disconnect.c +++ b/tests/functionaltests/test_disconnect.c @@ -1,3 +1,11 @@ +/* + * test_disconnect.c + * + * Copyright (C) 2016 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/functionaltests/test_disconnect.h b/tests/functionaltests/test_disconnect.h index b65f5766..c1ae06ba 100644 --- a/tests/functionaltests/test_disconnect.h +++ b/tests/functionaltests/test_disconnect.h @@ -1 +1,9 @@ +/* + * test_disconnect.h + * + * Copyright (C) 2016 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void disconnect_ends_session(void** state); diff --git a/tests/functionaltests/test_message.c b/tests/functionaltests/test_message.c index 1bc3760d..bd0b836d 100644 --- a/tests/functionaltests/test_message.c +++ b/tests/functionaltests/test_message.c @@ -1,3 +1,11 @@ +/* + * test_message.c + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/functionaltests/test_message.h b/tests/functionaltests/test_message.h index c0b4c559..6a570bb4 100644 --- a/tests/functionaltests/test_message.h +++ b/tests/functionaltests/test_message.h @@ -1,3 +1,11 @@ +/* + * test_message.h + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void message_send(void** state); void message_receive_console(void** state); void message_receive_chatwin(void** state); diff --git a/tests/functionaltests/test_muc.c b/tests/functionaltests/test_muc.c index 18db45ab..98b72899 100644 --- a/tests/functionaltests/test_muc.c +++ b/tests/functionaltests/test_muc.c @@ -1,3 +1,11 @@ +/* + * test_muc.c + * + * Copyright (C) 2015 - 2018 James Booth + * Copyright (C) 2019 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/functionaltests/test_muc.h b/tests/functionaltests/test_muc.h index 31df8944..95de0c28 100644 --- a/tests/functionaltests/test_muc.h +++ b/tests/functionaltests/test_muc.h @@ -1,3 +1,11 @@ +/* + * test_muc.h + * + * Copyright (C) 2015 - 2018 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void sends_room_join(void** state); void sends_room_join_with_nick(void** state); void sends_room_join_with_password(void** state); diff --git a/tests/functionaltests/test_ping.c b/tests/functionaltests/test_ping.c index ed9eeddf..b62fb7b9 100644 --- a/tests/functionaltests/test_ping.c +++ b/tests/functionaltests/test_ping.c @@ -1,3 +1,11 @@ +/* + * test_ping.c + * + * Copyright (C) 2015 - 2017 James Booth + * Copyright (C) 2019 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include @@ -11,15 +19,15 @@ void ping_server(void** state) { stbbr_for_query("http://jabber.org/protocol/disco#info", - "" - "" - "" - "" - "" - ""); + "" + "" + "" + "" + "" + ""); stbbr_for_xmlns("urn:xmpp:ping", - ""); + ""); prof_connect(); @@ -42,11 +50,11 @@ void ping_server_not_supported(void** state) { stbbr_for_query("http://jabber.org/protocol/disco#info", - "" - "" - "" - "" - ""); + "" + "" + "" + "" + ""); prof_connect(); @@ -82,7 +90,7 @@ ping_jid(void** state) ""); stbbr_for_xmlns("urn:xmpp:ping", - ""); + ""); prof_connect(); diff --git a/tests/functionaltests/test_ping.h b/tests/functionaltests/test_ping.h index 90598598..52511f36 100644 --- a/tests/functionaltests/test_ping.h +++ b/tests/functionaltests/test_ping.h @@ -1,3 +1,11 @@ +/* + * test_ping.h + * + * Copyright (C) 2015 - 2017 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void ping_server(void** state); void ping_server_not_supported(void** state); void ping_responds_to_server_request(void** state); diff --git a/tests/functionaltests/test_presence.c b/tests/functionaltests/test_presence.c index da48a9c1..eedf8729 100644 --- a/tests/functionaltests/test_presence.c +++ b/tests/functionaltests/test_presence.c @@ -1,3 +1,11 @@ +/* + * test_presence.c + * + * Copyright (C) 2015 - 2017 James Booth + * Copyright (C) 2019 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/functionaltests/test_presence.h b/tests/functionaltests/test_presence.h index 0efd9ead..d146d8ec 100644 --- a/tests/functionaltests/test_presence.h +++ b/tests/functionaltests/test_presence.h @@ -1,3 +1,11 @@ +/* + * test_presence.h + * + * Copyright (C) 2015 - 2017 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void presence_away(void** state); void presence_away_with_message(void** state); void presence_online(void** state); diff --git a/tests/functionaltests/test_receipts.c b/tests/functionaltests/test_receipts.c index a8efe546..a82528a3 100644 --- a/tests/functionaltests/test_receipts.c +++ b/tests/functionaltests/test_receipts.c @@ -1,3 +1,11 @@ +/* + * test_receipts.c + * + * Copyright (C) 2015 - 2016 James Booth + * Copyright (C) 2019 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/functionaltests/test_receipts.h b/tests/functionaltests/test_receipts.h index a62cfc63..61d9b40a 100644 --- a/tests/functionaltests/test_receipts.h +++ b/tests/functionaltests/test_receipts.h @@ -1,3 +1,11 @@ +/* + * test_receipts.h + * + * Copyright (C) 2015 - 2016 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void does_not_send_receipt_request_to_barejid(void** state); void send_receipt_request(void** state); void send_receipt_on_request(void** state); diff --git a/tests/functionaltests/test_rooms.c b/tests/functionaltests/test_rooms.c index 2097a56c..73a2853c 100644 --- a/tests/functionaltests/test_rooms.c +++ b/tests/functionaltests/test_rooms.c @@ -1,3 +1,11 @@ +/* + * test_rooms.c + * + * Copyright (C) 2015 - 2018 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include @@ -11,12 +19,12 @@ void rooms_query(void** state) { stbbr_for_query("http://jabber.org/protocol/disco#items", - "" - "" - "" - "" - "" - ""); + "" + "" + "" + "" + "" + ""); prof_connect(); diff --git a/tests/functionaltests/test_rooms.h b/tests/functionaltests/test_rooms.h index eec4cb5f..72b78957 100644 --- a/tests/functionaltests/test_rooms.h +++ b/tests/functionaltests/test_rooms.h @@ -1 +1,9 @@ +/* + * test_rooms.h + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void rooms_query(void** state); diff --git a/tests/functionaltests/test_roster.c b/tests/functionaltests/test_roster.c index 919024b8..daed0a4b 100644 --- a/tests/functionaltests/test_roster.c +++ b/tests/functionaltests/test_roster.c @@ -1,3 +1,11 @@ +/* + * test_roster.c + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/functionaltests/test_roster.h b/tests/functionaltests/test_roster.h index 51daea81..6e3ac024 100644 --- a/tests/functionaltests/test_roster.h +++ b/tests/functionaltests/test_roster.h @@ -1,3 +1,11 @@ +/* + * test_roster.h + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void sends_new_item(void** state); void sends_new_item_nick(void** state); void sends_remove_item(void** state); diff --git a/tests/functionaltests/test_software.c b/tests/functionaltests/test_software.c index 9bdbda5a..0bba11d7 100644 --- a/tests/functionaltests/test_software.c +++ b/tests/functionaltests/test_software.c @@ -1,3 +1,11 @@ +/* + * test_software.c + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/functionaltests/test_software.h b/tests/functionaltests/test_software.h index bae351e7..dec98af8 100644 --- a/tests/functionaltests/test_software.h +++ b/tests/functionaltests/test_software.h @@ -1,3 +1,11 @@ +/* + * test_software.h + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2026 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void send_software_version_request(void** state); void display_software_version_result(void** state); void shows_message_when_software_version_error(void** state); diff --git a/tests/unittests/config/stub_accounts.c b/tests/unittests/config/stub_accounts.c index c805e3ba..8579a671 100644 --- a/tests/unittests/config/stub_accounts.c +++ b/tests/unittests/config/stub_accounts.c @@ -1,3 +1,11 @@ +/* + * stub_accounts.c + * + * Copyright (C) 2015 - 2016 James Booth + * Copyright (C) 2020 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later WITH OpenSSL-exception + */ #include "prof_cmocka.h" #include "common.h" diff --git a/tests/unittests/helpers.c b/tests/unittests/helpers.c index 83de34a0..bcbc2410 100644 --- a/tests/unittests/helpers.c +++ b/tests/unittests/helpers.c @@ -1,3 +1,11 @@ +/* + * helpers.c + * + * Copyright (C) 2015 - 2016 James Booth + * Copyright (C) 2015 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "prof_cmocka.h" #include diff --git a/tests/unittests/helpers.h b/tests/unittests/helpers.h index 0ee2f2c4..73c8e083 100644 --- a/tests/unittests/helpers.h +++ b/tests/unittests/helpers.h @@ -1,3 +1,11 @@ +/* + * helpers.h + * + * Copyright (C) 2015 James Booth + * Copyright (C) 2020 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include "glib.h" int load_preferences(void** state); diff --git a/tests/unittests/otr/stub_otr.c b/tests/unittests/otr/stub_otr.c index 8069ee7d..179b4dab 100644 --- a/tests/unittests/otr/stub_otr.c +++ b/tests/unittests/otr/stub_otr.c @@ -1,3 +1,11 @@ +/* + * stub_otr.c + * + * Copyright (C) 2015 - 2016 James Booth + * Copyright (C) 2020 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include #include diff --git a/tests/unittests/pgp/stub_gpg.c b/tests/unittests/pgp/stub_gpg.c index c298b12e..d0fd567c 100644 --- a/tests/unittests/pgp/stub_gpg.c +++ b/tests/unittests/pgp/stub_gpg.c @@ -1,3 +1,11 @@ +/* + * stub_gpg.c + * + * Copyright (C) 2015 - 2017 James Booth + * Copyright (C) 2020 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include "pgp/gpg.h" diff --git a/tests/unittests/test_common.c b/tests/unittests/test_common.c index 822ea7e5..cd62c84d 100644 --- a/tests/unittests/test_common.c +++ b/tests/unittests/test_common.c @@ -1,3 +1,11 @@ +/* + * test_common.c + * + * Copyright (C) 2015 - 2017 James Booth + * Copyright (C) 2015 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include "xmpp/resource.h" #include "common.h" #include "prof_cmocka.h" diff --git a/tests/unittests/test_common.h b/tests/unittests/test_common.h index 0bd72943..50ce1262 100644 --- a/tests/unittests/test_common.h +++ b/tests/unittests/test_common.h @@ -1,3 +1,11 @@ +/* + * test_common.h + * + * Copyright (C) 2015 - 2016 James Booth + * Copyright (C) 2018 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #ifndef TESTS_TEST_COMMON_H #define TESTS_TEST_COMMON_H diff --git a/tests/unittests/tools/stub_http_upload.c b/tests/unittests/tools/stub_http_upload.c index d1d0e59c..99171944 100644 --- a/tests/unittests/tools/stub_http_upload.c +++ b/tests/unittests/tools/stub_http_upload.c @@ -1,3 +1,11 @@ +/* + * stub_http_upload.c + * + * Copyright (C) 2017 James Booth + * Copyright (C) 2020 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #ifndef TOOLS_HTTP_UPLOAD_H #define TOOLS_HTTP_UPLOAD_H diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 178ed9d8..4beb6200 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -1,3 +1,11 @@ +/* + * stub_ui.c + * + * Copyright (C) 2015 - 2018 James Booth + * Copyright (C) 2019 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include "config.h" #include diff --git a/tests/unittests/ui/stub_ui.h b/tests/unittests/ui/stub_ui.h index faff0710..21ea5bbf 100644 --- a/tests/unittests/ui/stub_ui.h +++ b/tests/unittests/ui/stub_ui.h @@ -1,3 +1,11 @@ +/* + * stub_ui.h + * + * Copyright (C) 2015 - 2016 James Booth + * Copyright (C) 2015 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ void expect_cons_show(char* expected); void expect_any_cons_show(void); void expect_cons_show_error(char* expected); diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c index ee81d4f8..1dede0e5 100644 --- a/tests/unittests/unittests.c +++ b/tests/unittests/unittests.c @@ -1,3 +1,11 @@ +/* + * unittests.c + * + * Copyright (C) 2015 - 2018 James Booth + * Copyright (C) 2018 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include #include #include diff --git a/tests/unittests/xmpp/stub_xmpp.c b/tests/unittests/xmpp/stub_xmpp.c index 76a072e9..3f32e734 100644 --- a/tests/unittests/xmpp/stub_xmpp.c +++ b/tests/unittests/xmpp/stub_xmpp.c @@ -1,3 +1,11 @@ +/* + * stub_xmpp.c + * + * Copyright (C) 2015 - 2018 James Booth + * Copyright (C) 2019 - 2026 Michael Vetter + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ #include "prof_cmocka.h" #include "xmpp/xmpp.h"