I had a search round the forum and found a post explaining it could be printing the pointer value. I am not so sure about that. I am using sqlite3.
Why am I seeing these odd characters? I honestly cannot for the life of me figure it out.
Many thanks.
Output example:
Code:
chrono_search(): ��|�
chrono_search() is where strange characters
Code:
void _concatenate_search_term()
{
search_term = (char *)malloc((list_count(_word_head) + 1) * sizeof(char));
node_t * current = _word_head;
while (current != NULL)
{
strncat(search_term, current->value, strlen(current->value));
current = current->next;
}
}
int chrono_check_word()
{
_concatenate_search_term();
printf("query: %s\n", search_term);
printf("restricted: %d\n", list_count(_restricted_words));
node_t * current = _restricted_words;
while (current != NULL)
{
if (strcmp(current->value, search_term) == 0)
{
// chrono_process_name();
chrono_reset();
printf("found!\n");
chrono_socket_write("restricted");
return RESTRICTED;
}
printf("chrono_search(): %s\n", current->value);
current = current->next;
}
/* reset the search terms and word head. free() */
chrono_reset();
return ALLOWED;
}
DB
Code:
int select_callback(void * not_used, int argc, char * argv[], char ** col_name)
{
not_used = 0;
size_t len = strlen(*argv)+1;
const unsigned int restricted_col = 3;
char * value = *argv;
if (_restricted_words == NULL)
{
_restricted_words = list_create(value, NULL);
}
else
{
list_append(_restricted_words, value);
}
printf("%s\n", _restricted_words->value);
printf("%s\n", value);
return 0;
}
sqlite3 * db;
char * err_msg;
int rc = sqlite3_open("/usr/local/var/db/chronograff.db", &db);
if (rc != SQLITE_OK)
{
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
exit(EXIT_FAILURE);
}
const char * sql = "SELECT restricted FROM black_list WHERE constrained = 'command';";
rc = sqlite3_exec(db, sql, select_callback, 0, &err_msg);
if (rc != SQLITE_OK )
{
sqlite3_free(err_msg);
sqlite3_close(db);
exit(EXIT_FAILURE);
}
sqlite3_close(db);