more fixes for chat
This commit is contained in:
parent
0d89741851
commit
14aef25985
@ -41,7 +41,7 @@ static char *encapsulate_quote(char *in) {
|
||||
int i;
|
||||
int j = 0;
|
||||
for (i=0;i<strlen(in);i++) {
|
||||
if (in[j] == '\"') {
|
||||
if (in[j] == '\"' || in[j] == '\\') {
|
||||
out[i++] = '\\';
|
||||
}
|
||||
out[i] = in[j];
|
||||
@ -155,7 +155,7 @@ void chat_system(struct user_record *user) {
|
||||
return;
|
||||
}
|
||||
|
||||
jsmn_init(&parser);
|
||||
|
||||
|
||||
row_at = 0;
|
||||
line_at = 0;
|
||||
@ -255,6 +255,7 @@ void chat_system(struct user_record *user) {
|
||||
}
|
||||
|
||||
// json parse
|
||||
jsmn_init(&parser);
|
||||
// we got some data from a client
|
||||
r = jsmn_parse(&parser, readbuffer, len, tokens, sizeof(tokens)/sizeof(tokens[0]));
|
||||
|
||||
|
@ -85,7 +85,6 @@ int main(int argc, char **argv) {
|
||||
|
||||
c = sizeof(struct sockaddr_in);
|
||||
|
||||
jsmn_init(&parser);
|
||||
|
||||
while (1) {
|
||||
read_fds = master;
|
||||
@ -165,6 +164,8 @@ int main(int argc, char **argv) {
|
||||
FD_CLR(i, &master); // remove from master set
|
||||
} else {
|
||||
// we got some data from a client
|
||||
|
||||
jsmn_init(&parser);
|
||||
r = jsmn_parse(&parser, buf, nbytes, tokens, sizeof(tokens)/sizeof(tokens[0]));
|
||||
|
||||
if (r < 0) {
|
||||
|
Reference in New Issue
Block a user