1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 21:03:27 +01:00

add str_to_lower function, ignore DNS domain name case

This commit is contained in:
Jfreegman 2014-06-18 13:10:20 -04:00
parent fc148be3e2
commit 72e9e7d9c4
4 changed files with 20 additions and 12 deletions

View File

@ -37,8 +37,8 @@
#include "line_info.h"
#include "dns.h"
#include "global_commands.h"
#include "misc_tools.h"
#define MAX_DNS_THREADS 10
#define MAX_DNS_REQST_SIZE 256
#define NUM_DNS3_SERVERS 1 /* must correspond to number of items in dns3_servers array */
#define TOX_DNS3_TXT_PREFIX "v=tox3;id="
@ -173,6 +173,7 @@ static int parse_addr(uint8_t *addr, uint8_t *namebuf, uint8_t *dombuf)
if (tmpname == NULL || tmpdom == NULL)
return -1;
str_to_lower(tmpdom);
strcpy(namebuf, tmpname);
strcpy(dombuf, tmpdom);
@ -190,7 +191,7 @@ void *dns3_lookup_thread(void *data)
int namelen = parse_addr(t_data.addr, name, domain);
if (namelen == -1) {
dns_error(self, "Must be a Tox key or an address in the form username@domain");
dns_error(self, "Must be a Tox ID or an address in the form username@domain");
kill_dns_thread(NULL);
}
@ -245,9 +246,8 @@ void *dns3_lookup_thread(void *data)
uint8_t ans_id[MAX_DNS_REQST_SIZE];
/* extract TXT from DNS response */
if (parse_dns_response(self, answer, ans_len, ans_id) == -1) {
if (parse_dns_response(self, answer, ans_len, ans_id) == -1)
kill_dns_thread(dns_obj);
}
uint8_t encrypted_id[MAX_DNS_REQST_SIZE];
int prfx_len = strlen(TOX_DNS3_TXT_PREFIX);

View File

@ -461,20 +461,16 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
}
char *status = argv[1];
str_to_lower(status);
int len = strlen(status);
char l_status[len + 1];
int i;
for (i = 0; i <= len; ++i)
l_status[i] = tolower(status[i]);
TOX_USERSTATUS status_kind;
if (!strcmp(l_status, "online"))
if (!strcmp(status, "online"))
status_kind = TOX_USERSTATUS_NONE;
else if (!strcmp(l_status, "away"))
else if (!strcmp(status, "away"))
status_kind = TOX_USERSTATUS_AWAY;
else if (!strcmp(l_status, "busy"))
else if (!strcmp(status, "busy"))
status_kind = TOX_USERSTATUS_BUSY;
else {
errmsg = "Invalid status. Valid statuses are: online, busy and away.";

View File

@ -250,3 +250,12 @@ void get_file_name(uint8_t *namebuf, uint8_t *pathname)
snprintf(namebuf, MAX_STR_SIZE, "%s", filename);
}
/* converts str to all lowercase */
void str_to_lower(uint8_t *str)
{
int i;
for (i = 0; str[i]; ++i)
str[i] = tolower(str[i]);
}

View File

@ -86,4 +86,7 @@ void mv_curs_end(WINDOW *w, size_t len, int max_y, int max_x);
/* gets base file name from path or original file name if no path is supplied */
void get_file_name(uint8_t *namebuf, uint8_t *pathname);
/* converts str to all uppercase */
void str_to_lower(uint8_t *str);
#endif /* #define _misc_tools_h */