1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-10-13 20:13:38 -04:00

Merge branch 'master' into type_out

This commit is contained in:
James Booth 2012-10-22 22:21:55 +01:00
commit a5e4e52567
39 changed files with 722 additions and 623 deletions

40
cygwin
View File

@ -1,40 +0,0 @@
Install cygwin:
http://www.cygwin.com/
http://cygwin.com/setup.exe
Choose git and wget
wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg
chmod +x apt-cyg
mv apt-cyg /usr/local/bin/
apt-cyg install make gcc automake autoconf pkg-config openssl-devel expat zlib-devel libncurses-devel libncurses-devel libxml2-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel
ln -s /usr/bin/gcc-3.exe /usr/bin/gcc.exe
ln -s /usr/bin/g++-3.exe /usr/bin/g++.exe
mkdir projects-git
git clone git://github.com/boothj5/profanity.git
cd profanity
git clone git://github.com/boothj5/head-unit.git
cd head-unit
make
make install
cd ..
git clone git://github.com/metajack/libstrophe.git
cd libstrophe
./bootstrap.sh
./bootstrap.sh
./configure
make
make install
cd ..
./bootstrap.sh
./configure
make
make install

View File

@ -155,3 +155,5 @@ with contributions from:
Dolan O'Toole
.br
Colin Bradley
.br
Dmitry Podgorny <pasis.ua@gmail.com>

View File

@ -1,5 +0,0 @@
#!/bin/sh
rm -f tags
rm -f cscope.out
ctags -R .
cscope -R -b

View File

@ -1,4 +0,0 @@
#!/bin/sh
rm -f valgrind.out
#valgrind --log-file=valgrind.out --leak-check=full --track-origins=yes --show-reachable=yes ./profanity
valgrind --log-file=valgrind.out --leak-check=full --track-origins=yes ./profanity -l DEBUG

View File

@ -116,7 +116,7 @@ chat_log_get_previous(const gchar * const login, const gchar * const recipient,
char *line = NULL;
size_t read = 0;
if (logp != NULL) {
GString *gs_header = g_string_new("Log ");
GString *gs_header = g_string_new("");
g_string_append_printf(gs_header, "%d/%d/%d:",
g_date_time_get_day_of_month(log_date),
g_date_time_get_month(log_date),

View File

@ -54,9 +54,8 @@ struct cmd_t {
static struct cmd_t * _cmd_get_command(const char * const command);
static void _update_presence(const jabber_presence_t presence,
const char * const show, const char * const inp);
static gboolean
_cmd_set_boolean_preference(const char * const inp, struct cmd_help_t help,
const char * const cmd_str, const char * const display,
static gboolean _cmd_set_boolean_preference(const char * const inp,
struct cmd_help_t help, const char * const cmd_str, const char * const display,
void (*set_func)(gboolean));
// command prototypes
@ -353,6 +352,7 @@ static struct cmd_t status_commands[] =
};
static PAutocomplete commands_ac;
static PAutocomplete help_ac;
/*
* Initialise command autocompleter and history
@ -362,26 +362,37 @@ cmd_init(void)
{
log_info("Initialising commands");
commands_ac = p_autocomplete_new();
help_ac = p_autocomplete_new();
unsigned int i;
for (i = 0; i < ARRAY_SIZE(main_commands); i++) {
struct cmd_t *pcmd = main_commands+i;
p_autocomplete_add(commands_ac, (gchar *)pcmd->cmd);
p_autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd));
p_autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1));
}
for (i = 0; i < ARRAY_SIZE(setting_commands); i++) {
struct cmd_t *pcmd = setting_commands+i;
p_autocomplete_add(commands_ac, (gchar *)pcmd->cmd);
p_autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd));
p_autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1));
}
for (i = 0; i < ARRAY_SIZE(status_commands); i++) {
struct cmd_t *pcmd = status_commands+i;
p_autocomplete_add(commands_ac, (gchar *)pcmd->cmd);
p_autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd));
p_autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1));
}
history_init();
}
void
cmd_close(void)
{
p_autocomplete_clear(commands_ac);
p_autocomplete_clear(help_ac);
}
// Command autocompletion functions
char *
@ -397,6 +408,17 @@ cmd_reset_completer(void)
}
// Command help
char *
cmd_help_complete(char *inp)
{
return p_autocomplete_complete(help_ac, inp);
}
void
cmd_help_reset_completer(void)
{
p_autocomplete_reset(help_ac);
}
GSList *
cmd_get_basic_help(void)

View File

@ -33,12 +33,15 @@ struct cmd_help_t {
};
void cmd_init(void);
void cmd_close(void);
char * cmd_complete(char *inp);
void cmd_reset_completer(void);
gboolean cmd_execute(const char * const command, const char * const inp);
gboolean cmd_execute_default(const char * const inp);
// command help
char * cmd_help_complete(char *inp);
void cmd_help_reset_completer(void);
GSList * cmd_get_basic_help(void);
GSList * cmd_get_settings_help(void);
GSList * cmd_get_status_help(void);

View File

@ -43,7 +43,7 @@ contact_list_clear(void)
}
void
reset_search_attempts(void)
contact_list_reset_search_attempts(void)
{
p_autocomplete_reset(ac);
}
@ -68,7 +68,7 @@ get_contact_list(void)
}
char *
find_contact(char *search_str)
contact_list_find_contact(char *search_str)
{
return p_autocomplete_complete(ac, search_str);
}

View File

@ -29,12 +29,12 @@
void contact_list_init(void);
void contact_list_clear(void);
void reset_search_attempts(void);
void contact_list_reset_search_attempts(void);
gboolean contact_list_add(const char * const name, const char * const show,
const char * const status);
gboolean contact_list_remove(const char * const name);
GSList * get_contact_list(void);
char * find_contact(char *search_str);
char * contact_list_find_contact(char *search_str);
PContact contact_list_get_contact(const char const *jid);
#endif

View File

@ -58,12 +58,16 @@
#include "preferences.h"
#include "ui.h"
typedef char*(*autocomplete_func)(char *);
static WINDOW *inp_win;
static int pad_start = 0;
static int _handle_edit(const int ch, char *input, int *size);
static int _printable(const int ch);
static void _replace_input(char *input, const char * const new_input, int *size);
static void _parameter_autocomplete(char *input, int *size, char *command,
autocomplete_func func);
void
create_input_window(void)
@ -160,8 +164,10 @@ inp_get_char(int *ch, char *input, int *size)
}
}
reset_search_attempts();
reset_login_search();
contact_list_reset_search_attempts();
prefs_reset_login_search();
prefs_reset_boolean_choice();
cmd_help_reset_completer();
cmd_reset_completer();
}
}
@ -216,7 +222,7 @@ _handle_edit(const int ch, char *input, int *size)
case 127:
case KEY_BACKSPACE:
reset_search_attempts();
contact_list_reset_search_attempts();
if (*size > 0) {
// if at end, delete last char
@ -319,7 +325,7 @@ _handle_edit(const int ch, char *input, int *size)
case 9: // tab
// autocomplete commands
// autocomplete command
if ((strncmp(input, "/", 1) == 0) && (!str_contains(input, *size, ' '))) {
for(i = 0; i < *size; i++) {
inp_cpy[i] = input[i];
@ -333,39 +339,29 @@ _handle_edit(const int ch, char *input, int *size)
free(auto_msg);
free(found);
}
// autcomplete /msg recipient
} else if ((strncmp(input, "/msg ", 5) == 0) && (*size > 5)) {
for(i = 5; i < *size; i++) {
inp_cpy[i-5] = input[i];
}
inp_cpy[(*size) - 5] = '\0';
found = find_contact(inp_cpy);
if (found != NULL) {
auto_msg = (char *) malloc((5 + (strlen(found) + 1)) * sizeof(char));
strcpy(auto_msg, "/msg ");
strcat(auto_msg, found);
_replace_input(input, auto_msg, size);
free(auto_msg);
free(found);
}
// autocomplete /connect username
} else if ((strncmp(input, "/connect ", 9) == 0) && (*size > 9)) {
for(i = 9; i < *size; i++) {
inp_cpy[i-9] = input[i];
}
inp_cpy[(*size) - 9] = '\0';
found = find_login(inp_cpy);
if (found != NULL) {
auto_msg = (char *) malloc((9 + (strlen(found) + 1)) * sizeof(char));
strcpy(auto_msg, "/connect ");
strcat(auto_msg, found);
_replace_input(input, auto_msg, size);
free(auto_msg);
free(found);
}
}
_parameter_autocomplete(input, size, "/msg",
contact_list_find_contact);
_parameter_autocomplete(input, size, "/connect",
prefs_find_login);
_parameter_autocomplete(input, size, "/help",
cmd_help_complete);
_parameter_autocomplete(input, size, "/beep",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/notify",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/typing",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/flash",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/showsplash",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/chlog",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/history",
prefs_autocomplete_boolean_choice);
return 1;
default:
@ -396,3 +392,32 @@ _replace_input(char *input, const char * const new_input, int *size)
for (i = 0; i < *size; i++)
waddch(inp_win, input[i]);
}
static void
_parameter_autocomplete(char *input, int *size, char *command,
autocomplete_func func)
{
char *found = NULL;
char *auto_msg = NULL;
char inp_cpy[*size];
int i;
char *command_cpy = malloc(strlen(command) + 2);
sprintf(command_cpy, "%s ", command);
int len = strlen(command_cpy);
if ((strncmp(input, command_cpy, len) == 0) && (*size > len)) {
for(i = len; i < *size; i++) {
inp_cpy[i-len] = input[i];
}
inp_cpy[(*size) - len] = '\0';
found = func(inp_cpy);
if (found != NULL) {
auto_msg = (char *) malloc((len + (strlen(found) + 1)) * sizeof(char));
strcpy(auto_msg, command_cpy);
strcat(auto_msg, found);
_replace_input(input, auto_msg, size);
free(auto_msg);
free(found);
}
}
free(command_cpy);
}

View File

@ -243,10 +243,46 @@ jabber_get_jid(void)
return xmpp_conn_get_jid(jabber_conn.conn);
}
void
jabber_free_resources(void)
{
xmpp_conn_release(jabber_conn.conn);
xmpp_ctx_free(jabber_conn.ctx);
xmpp_shutdown();
}
static int
_message_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata)
{
char *type = NULL;
char *from = NULL;
type = xmpp_stanza_get_attribute(stanza, "type");
from = xmpp_stanza_get_attribute(stanza, "from");
if (type != NULL) {
if (strcmp(type, "error") == 0) {
char *err_msg = NULL;
xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, "error");
if (error == NULL) {
log_debug("error message without <error/> received");
return 1;
} else {
xmpp_stanza_t *err_cond = xmpp_stanza_get_children(error);
if (err_cond == NULL) {
log_debug("error message without <defined-condition/> received");
return 1;
} else {
err_msg = xmpp_stanza_get_name(err_cond);
}
// TODO: process 'type' attribute from <error/> [RFC6120, 8.3.2]
}
prof_handle_error_message(from, err_msg);
return 1;
}
}
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body");
// if no message, check for chatstates
@ -257,7 +293,6 @@ _message_handler(xmpp_conn_t * const conn,
// active
} else if (xmpp_stanza_get_child_by_name(stanza, "composing") != NULL) {
// composing
char *from = xmpp_stanza_get_attribute(stanza, "from");
prof_handle_typing(from);
}
}
@ -266,12 +301,7 @@ _message_handler(xmpp_conn_t * const conn,
}
// message body recieved
char *type = xmpp_stanza_get_attribute(stanza, "type");
if(strcmp(type, "error") == 0)
return 1;
char *message = xmpp_stanza_get_text(body);
char *from = xmpp_stanza_get_attribute(stanza, "from");
prof_handle_incoming_message(from, message);
return 1;
@ -306,13 +336,6 @@ _connection_handler(xmpp_conn_t * const conn,
// received close stream response from server after disconnect
if (jabber_conn.conn_status == JABBER_DISCONNECTING) {
// free memory for connection object and context
xmpp_conn_release(jabber_conn.conn);
xmpp_ctx_free(jabber_conn.ctx);
// shutdown libstrophe
xmpp_shutdown();
jabber_conn.conn_status = JABBER_DISCONNECTED;
jabber_conn.presence = PRESENCE_OFFLINE;

View File

@ -50,5 +50,6 @@ void jabber_send(const char * const msg, const char * const recipient);
void jabber_update_presence(jabber_presence_t status, const char * const msg);
const char * jabber_get_jid(void);
jabber_conn_status_t jabber_get_connection_status(void);
void jabber_free_resources(void);
#endif

View File

@ -39,8 +39,8 @@
static GString *prefs_loc;
static GKeyFile *prefs;
// search logins list
static PAutocomplete ac;
static PAutocomplete login_ac;
static PAutocomplete boolean_choice_ac;
struct colour_string_t {
char *str;
@ -87,7 +87,7 @@ void
prefs_load(void)
{
log_info("Loading preferences");
ac = p_autocomplete_new();
login_ac = p_autocomplete_new();
prefs_loc = g_string_new(getenv("HOME"));
g_string_append(prefs_loc, "/.profanity/config");
@ -102,7 +102,7 @@ prefs_load(void)
gsize i;
for (i = 0; i < njids; i++) {
p_autocomplete_add(ac, strdup(jids[i]));
p_autocomplete_add(login_ac, strdup(jids[i]));
}
for (i = 0; i < njids; i++) {
@ -110,13 +110,19 @@ prefs_load(void)
}
free(jids);
_load_colours();
boolean_choice_ac = p_autocomplete_new();
p_autocomplete_add(boolean_choice_ac, strdup("on"));
p_autocomplete_add(boolean_choice_ac, strdup("off"));
}
void
prefs_close(void)
{
p_autocomplete_clear(login_ac);
p_autocomplete_clear(boolean_choice_ac);
g_key_file_free(prefs);
}
@ -193,15 +199,27 @@ _load_colours(void)
}
char *
find_login(char *prefix)
prefs_find_login(char *prefix)
{
return p_autocomplete_complete(ac, prefix);
return p_autocomplete_complete(login_ac, prefix);
}
void
reset_login_search(void)
prefs_reset_login_search(void)
{
p_autocomplete_reset(ac);
p_autocomplete_reset(login_ac);
}
char *
prefs_autocomplete_boolean_choice(char *prefix)
{
return p_autocomplete_complete(boolean_choice_ac, prefix);
}
void
prefs_reset_boolean_choice(void)
{
p_autocomplete_reset(boolean_choice_ac);
}
gboolean

View File

@ -37,8 +37,10 @@
void prefs_load(void);
void prefs_close(void);
char * find_login(char *prefix);
void reset_login_search(void);
char * prefs_find_login(char *prefix);
void prefs_reset_login_search(void);
char * prefs_autocomplete_boolean_choice(char *prefix);
void prefs_reset_boolean_choice(void);
gboolean prefs_get_beep(void);
void prefs_set_beep(gboolean value);

View File

@ -116,6 +116,24 @@ prof_handle_incoming_message(char *from, char *message)
}
}
void
prof_handle_error_message(const char *from, const char *err_msg)
{
char *msg, *fmt;
if (err_msg != NULL) {
fmt = "Error received from server: %s";
msg = (char *)malloc(strlen(err_msg) + strlen(fmt) - 1);
if (msg == NULL)
goto loop_out;
sprintf(msg, fmt, err_msg);
cons_bad_show(msg);
free(msg);
}
loop_out:
win_show_error_msg(from, err_msg);
}
void
prof_handle_login_success(const char *jid)
{
@ -175,7 +193,7 @@ prof_handle_roster(GSList *roster)
jabber_roster_entry *entry = roster->data;
// if contact not in contact list add them as offline
if (find_contact(entry->jid) == NULL) {
if (contact_list_find_contact(entry->jid) == NULL) {
contact_list_add(entry->jid, "offline", NULL);
}
@ -251,7 +269,7 @@ _process_input(char *inp)
}
inp_clear();
reset_search_attempts();
contact_list_reset_search_attempts();
win_page_off();
return result;
@ -283,6 +301,7 @@ _shutdown_init(void)
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
jabber_process_events();
}
jabber_free_resources();
}
_shutdown();
@ -291,8 +310,10 @@ _shutdown_init(void)
static void
_shutdown(void)
{
contact_list_clear();
gui_close();
chat_log_close();
prefs_close();
cmd_close();
log_close();
}

View File

@ -37,6 +37,7 @@ void prof_handle_typing(char *from);
void prof_handle_contact_online(char *contact, char *show, char *status);
void prof_handle_contact_offline(char *contact, char *show, char *status);
void prof_handle_incoming_message(char *from, char *message);
void prof_handle_error_message(const char *from, const char *err_msg);
void prof_handle_roster(GSList *roster);
#endif

View File

@ -88,6 +88,7 @@ int win_in_chat(void);
char *win_get_recipient(void);
void win_show_typing(const char * const from);
void win_show_incomming_msg(const char * const from, const char * const message);
void win_show_error_msg(const char * const from, const char *err_msg);
void win_show_outgoing_msg(const char * const from, const char * const to,
const char * const message);
void win_handle_special_keys(const int * const ch);

View File

@ -73,6 +73,7 @@ static void _win_switch_if_active(const int i);
static void _win_show_time(WINDOW *win);
static void _win_show_user(WINDOW *win, const char * const user, const int colour);
static void _win_show_message(WINDOW *win, const char * const message);
static void _win_show_error_msg(WINDOW *win, const char * const message);
static void _show_status_string(WINDOW *win, const char * const from,
const char * const show, const char * const status, const char * const pre,
const char * const default_show);
@ -83,6 +84,8 @@ static void _win_handle_switch(const int * const ch);
static void _win_handle_page(const int * const ch);
static void _win_resize_all(void);
static gint _win_get_unread(void);
static void _win_show_history(WINDOW *win, int win_index,
const char * const contact);
#ifdef HAVE_LIBNOTIFY
static void _win_notify(const char * const message, int timeout,
@ -284,15 +287,7 @@ win_show_incomming_msg(const char * const from, const char * const message)
_wins[win_index].unread++;
if (prefs_get_chlog() && prefs_get_history()) {
if (!_wins[win_index].history_shown) {
GSList *history = NULL;
history = chat_log_get_previous(jabber_get_jid(), short_from, history);
while (history != NULL) {
wprintw(win, "%s\n", history->data);
history = g_slist_next(history);
}
_wins[win_index].history_shown = 1;
}
_win_show_history(win, win_index, short_from);
}
_win_show_time(win);
@ -308,6 +303,27 @@ win_show_incomming_msg(const char * const from, const char * const message)
#endif
}
void
win_show_error_msg(const char * const from, const char *err_msg)
{
int win_index;
WINDOW *win;
if (from == NULL || err_msg == NULL)
return;
win_index = _find_prof_win_index(from);
// chat window exists
if (win_index < NUM_WINS) {
win = _wins[win_index].win;
_win_show_time(win);
_win_show_error_msg(win, err_msg);
if (win_index == _curr_prof_win) {
dirty = TRUE;
}
}
}
#ifdef HAVE_LIBNOTIFY
static void
_win_notify(const char * const message, int timeout,
@ -377,46 +393,35 @@ win_show_outgoing_msg(const char * const from, const char * const to,
{
// if the contact is offline, show a message
PContact contact = contact_list_get_contact(to);
int win_index = _find_prof_win_index(to);
WINDOW *win = NULL;
if (contact == NULL) {
cons_show("%s is not one of your contacts.");
} else {
int win_index = _find_prof_win_index(to);
WINDOW *win = NULL;
// create new window
if (win_index == NUM_WINS) {
win_index = _new_prof_win(to);
win = _wins[win_index].win;
// create new window
if (win_index == NUM_WINS) {
win_index = _new_prof_win(to);
win = _wins[win_index].win;
if (prefs_get_chlog() && prefs_get_history()) {
if (!_wins[win_index].history_shown) {
GSList *history = NULL;
history = chat_log_get_previous(jabber_get_jid(), to, history);
while (history != NULL) {
wprintw(win, "%s\n", history->data);
history = g_slist_next(history);
}
_wins[win_index].history_shown = 1;
}
}
if (prefs_get_chlog() && prefs_get_history()) {
_win_show_history(win, win_index, to);
}
if (contact != NULL) {
if (strcmp(p_contact_show(contact), "offline") == 0) {
const char const *show = p_contact_show(contact);
const char const *status = p_contact_status(contact);
_show_status_string(win, to, show, status, "--", "offline");
}
// use existing window
} else {
win = _wins[win_index].win;
}
_win_show_time(win);
_win_show_user(win, from, 0);
_win_show_message(win, message);
_win_switch_if_active(win_index);
// use existing window
} else {
win = _wins[win_index].win;
}
_win_show_time(win);
_win_show_user(win, from, 0);
_win_show_message(win, message);
_win_switch_if_active(win_index);
}
void
@ -915,6 +920,14 @@ _win_show_message(WINDOW *win, const char * const message)
wprintw(win, "%s\n", message);
}
static void
_win_show_error_msg(WINDOW *win, const char * const message)
{
wattron(win, COLOUR_ERR);
wprintw(win, "%s\n", message);
wattroff(win, COLOUR_ERR);
}
static void
_current_window_refresh(void)
{
@ -1097,3 +1110,19 @@ _win_get_unread(void)
return result;
}
static void
_win_show_history(WINDOW *win, int win_index, const char * const contact)
{
if (!_wins[win_index].history_shown) {
GSList *history = NULL;
history = chat_log_get_previous(jabber_get_jid(), contact, history);
while (history != NULL) {
wprintw(win, "%s\n", history->data);
history = g_slist_next(history);
}
_wins[win_index].history_shown = 1;
g_slist_free_full(history, free);
}
}

View File

@ -339,7 +339,7 @@ static void find_first_exists(void)
char *search = (char *) malloc(2 * sizeof(char));
strcpy(search, "B");
char *result = find_contact(search);
char *result = contact_list_find_contact(search);
assert_string_equals("Bob", result);
free(result);
free(search);
@ -351,7 +351,7 @@ static void find_second_exists(void)
contact_list_add("Dave", NULL, NULL);
contact_list_add("Bob", NULL, NULL);
char *result = find_contact("Dav");
char *result = contact_list_find_contact("Dav");
assert_string_equals("Dave", result);
free(result);
}
@ -362,7 +362,7 @@ static void find_third_exists(void)
contact_list_add("Dave", NULL, NULL);
contact_list_add("Bob", NULL, NULL);
char *result = find_contact("Ja");
char *result = contact_list_find_contact("Ja");
assert_string_equals("James", result);
free(result);
}
@ -373,13 +373,13 @@ static void find_returns_null(void)
contact_list_add("Dave", NULL, NULL);
contact_list_add("Bob", NULL, NULL);
char *result = find_contact("Mike");
char *result = contact_list_find_contact("Mike");
assert_is_null(result);
}
static void find_on_empty_returns_null(void)
{
char *result = find_contact("James");
char *result = contact_list_find_contact("James");
assert_is_null(result);
}
@ -389,8 +389,8 @@ static void find_twice_returns_second_when_two_match(void)
contact_list_add("Jamie", NULL, NULL);
contact_list_add("Bob", NULL, NULL);
char *result1 = find_contact("Jam");
char *result2 = find_contact(result1);
char *result1 = contact_list_find_contact("Jam");
char *result2 = contact_list_find_contact(result1);
assert_string_equals("Jamie", result2);
free(result1);
free(result2);
@ -409,11 +409,11 @@ static void find_five_times_finds_fifth(void)
contact_list_add("Jamy", NULL, NULL);
contact_list_add("Jamz", NULL, NULL);
char *result1 = find_contact("Jam");
char *result2 = find_contact(result1);
char *result3 = find_contact(result2);
char *result4 = find_contact(result3);
char *result5 = find_contact(result4);
char *result1 = contact_list_find_contact("Jam");
char *result2 = contact_list_find_contact(result1);
char *result3 = contact_list_find_contact(result2);
char *result4 = contact_list_find_contact(result3);
char *result5 = contact_list_find_contact(result4);
assert_string_equals("Jamo", result5);
free(result1);
free(result2);
@ -428,9 +428,9 @@ static void find_twice_returns_first_when_two_match_and_reset(void)
contact_list_add("Jamie", NULL, NULL);
contact_list_add("Bob", NULL, NULL);
char *result1 = find_contact("Jam");
reset_search_attempts();
char *result2 = find_contact(result1);
char *result1 = contact_list_find_contact("Jam");
contact_list_reset_search_attempts();
char *result2 = contact_list_find_contact(result1);
assert_string_equals("James", result2);
free(result1);
free(result2);
@ -444,10 +444,10 @@ static void removed_contact_not_in_search(void)
contact_list_add("James", NULL, NULL);
contact_list_add("Jamie", NULL, NULL);
char *result1 = find_contact("Jam"); // Jamatron
char *result2 = find_contact(result1); // Jambo
char *result1 = contact_list_find_contact("Jam"); // Jamatron
char *result2 = contact_list_find_contact(result1); // Jambo
contact_list_remove("James");
char *result3 = find_contact(result2);
char *result3 = contact_list_find_contact(result2);
assert_string_equals("Jamie", result3);
free(result1);
free(result2);