Mercurial > hg > nnchat
comparison main.c @ 481:73a648387d10
Improve error reporting.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 26 May 2012 08:40:37 +0300 |
parents | 4dca76db9e1f |
children | d48327519b17 |
comparison
equal
deleted
inserted
replaced
480:cb83967a0d9d | 481:73a648387d10 |
---|---|
360 if (!t) return 3; | 360 if (!t) return 3; |
361 *t = 0; | 361 *t = 0; |
362 | 362 |
363 // Decode message string | 363 // Decode message string |
364 msg = nn_decode_str1(msg); | 364 msg = nn_decode_str1(msg); |
365 if (!msg) return -1; | 365 if (!msg) |
366 { | |
367 errorMsg("Decode/malloc failure @ nnproto_parse_user()\n"); | |
368 return -1; | |
369 } | |
366 | 370 |
367 // Decode username | 371 // Decode username |
368 name = nn_decode_str1(name); | 372 name = nn_decode_str1(name); |
369 if (!name) | 373 if (!name) |
370 { | 374 { |
375 errorMsg("Decode/malloc failure @ nnproto_parse_user()\n"); | |
371 th_free(msg); | 376 th_free(msg); |
372 return -2; | 377 return -2; |
373 } | 378 } |
374 | 379 |
375 /* Check if the username is on our ignore list and | 380 /* Check if the username is on our ignore list and |
486 s = nn_conn_buf_strstr(conn, "</ADD_USER>"); | 491 s = nn_conn_buf_strstr(conn, "</ADD_USER>"); |
487 if (!s) return 1; | 492 if (!s) return 1; |
488 *s = 0; | 493 *s = 0; |
489 | 494 |
490 p = nn_dbldecode_str(str); | 495 p = nn_dbldecode_str(str); |
491 if (!p) return -1; | 496 if (!p) |
497 { | |
498 errorMsg("Decode/malloc failure @ nnproto_parse_add_user()\n"); | |
499 return -1; | |
500 } | |
492 | 501 |
493 win = nnwin_find(p); | 502 win = nnwin_find(p); |
494 nn_userhash_insert(nnUsers, nn_username_encode(p)); | 503 nn_userhash_insert(nnUsers, nn_username_encode(p)); |
495 | 504 |
496 printMsg(NULL, "! ˝3˝%s˝0˝ ˝2˝ADDED.˝0˝\n", p); | 505 printMsg(NULL, "! ˝3˝%s˝0˝ ˝2˝ADDED.˝0˝\n", p); |
510 s = nn_conn_buf_strstr(conn, "</DELETE_USER>"); | 519 s = nn_conn_buf_strstr(conn, "</DELETE_USER>"); |
511 if (!s) return 1; | 520 if (!s) return 1; |
512 *s = 0; | 521 *s = 0; |
513 | 522 |
514 p = nn_dbldecode_str(str); | 523 p = nn_dbldecode_str(str); |
515 if (!p) return -1; | 524 if (!p) |
525 { | |
526 errorMsg("Decode/malloc failure @ nnproto_parse_delete_user()\n"); | |
527 return -1; | |
528 } | |
516 | 529 |
517 win = nnwin_find(p); | 530 win = nnwin_find(p); |
518 nn_userhash_delete(nnUsers, nn_username_encode(p)); | 531 nn_userhash_delete(nnUsers, nn_username_encode(p)); |
519 | 532 |
520 printMsg(NULL, "! ˝3˝%s˝0˝ ˝1˝DELETED.˝0˝\n", p); | 533 printMsg(NULL, "! ˝3˝%s˝0˝ ˝1˝DELETED.˝0˝\n", p); |
1563 // Couldn't handle the message for some reason | 1576 // Couldn't handle the message for some reason |
1564 printMsg(currWin, "Could not handle: %s\n", conn->ptr); | 1577 printMsg(currWin, "Could not handle: %s\n", conn->ptr); |
1565 nn_conn_buf_skip(conn, strlen(conn->ptr) + 1); | 1578 nn_conn_buf_skip(conn, strlen(conn->ptr) + 1); |
1566 } | 1579 } |
1567 else | 1580 else |
1568 { | |
1569 // Fatal error, quit | |
1570 errorMsg("Fatal error with message: %s\n", conn->ptr); | |
1571 isError = TRUE; | 1581 isError = TRUE; |
1572 } | |
1573 } | 1582 } |
1574 } | 1583 } |
1575 else | 1584 else |
1576 if (cres < 0 || !nn_conn_check(conn)) | 1585 if (cres < 0 || !nn_conn_check(conn)) |
1577 isError = TRUE; | 1586 isError = TRUE; |