Mercurial > hg > nnchat
comparison main.c @ 639:02e1307e2a62
API changes in th_network module.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 04 Jul 2014 02:18:52 +0300 |
parents | bda973fa2b3b |
children | 51dd01786d25 |
comparison
equal
deleted
inserted
replaced
638:bda973fa2b3b | 639:02e1307e2a62 |
---|---|
634 { | 634 { |
635 BOOL isMine, isIgnored = FALSE; | 635 BOOL isMine, isIgnored = FALSE; |
636 char *name, *msg, *t; | 636 char *name, *msg, *t; |
637 | 637 |
638 // Find start of the message | 638 // Find start of the message |
639 name = conn->ptr; | 639 name = conn->base.ptr; |
640 t = th_conn_buf_strstr(conn, "</USER>"); | 640 t = th_conn_buf_strstr(conn, "</USER>"); |
641 if (!t) return 1; | 641 if (!t) return 1; |
642 *t = 0; | 642 *t = 0; |
643 | 643 |
644 // Find end of the message | 644 // Find end of the message |
645 t = th_conn_buf_strstr(conn, "<MESSAGE>"); | 645 t = th_conn_buf_strstr(conn, "<MESSAGE>"); |
646 if (!t) return 2; | 646 if (!t) return 2; |
647 msg = conn->ptr; | 647 msg = conn->base.ptr; |
648 | 648 |
649 t = th_conn_buf_strstr(conn, "</MESSAGE>"); | 649 t = th_conn_buf_strstr(conn, "</MESSAGE>"); |
650 if (!t) return 3; | 650 if (!t) return 3; |
651 *t = 0; | 651 *t = 0; |
652 | 652 |
797 } | 797 } |
798 | 798 |
799 | 799 |
800 int nnproto_parse_add_user(th_conn_t *conn) | 800 int nnproto_parse_add_user(th_conn_t *conn) |
801 { | 801 { |
802 char *p, *s, *str = conn->ptr; | 802 char *p, *s, *str = conn->base.ptr; |
803 nn_window_t *win; | 803 nn_window_t *win; |
804 | 804 |
805 s = th_conn_buf_strstr(conn, "</ADD_USER>"); | 805 s = th_conn_buf_strstr(conn, "</ADD_USER>"); |
806 if (!s) return 1; | 806 if (!s) return 1; |
807 *s = 0; | 807 *s = 0; |
825 } | 825 } |
826 | 826 |
827 | 827 |
828 int nnproto_parse_delete_user(th_conn_t *conn) | 828 int nnproto_parse_delete_user(th_conn_t *conn) |
829 { | 829 { |
830 char *p, *s, *str = conn->ptr; | 830 char *p, *s, *str = conn->base.ptr; |
831 nn_window_t *win; | 831 nn_window_t *win; |
832 | 832 |
833 s = th_conn_buf_strstr(conn, "</DELETE_USER>"); | 833 s = th_conn_buf_strstr(conn, "</DELETE_USER>"); |
834 if (!s) return 1; | 834 if (!s) return 1; |
835 *s = 0; | 835 *s = 0; |
908 return protoCmds[i].handler(conn); | 908 return protoCmds[i].handler(conn); |
909 } | 909 } |
910 | 910 |
911 if (optDebug) | 911 if (optDebug) |
912 { | 912 { |
913 printMsg(NULL, "Unknown protocmd: \"%s\"\n", conn->ptr); | 913 printMsg(NULL, "Unknown protocmd: \"%s\"\n", conn->base.ptr); |
914 return 0; | 914 return 0; |
915 } | 915 } |
916 else | 916 else |
917 return 1; | 917 return 1; |
918 } | 918 } |
2314 | 2314 |
2315 packet_retry: | 2315 packet_retry: |
2316 cres = th_conn_pull(conn); | 2316 cres = th_conn_pull(conn); |
2317 if (cres == TH_CONN_DATA_AVAIL) | 2317 if (cres == TH_CONN_DATA_AVAIL) |
2318 { | 2318 { |
2319 while (conn->ptr < conn->in_ptr && | 2319 while (conn->base.ptr < conn->base.in_ptr && |
2320 *(conn->in_ptr - 1) == 0 && | 2320 *(conn->base.in_ptr - 1) == 0 && |
2321 retries > 0 && !editState.isError) | 2321 retries > 0 && !editState.isError) |
2322 { | 2322 { |
2323 // th_conn_dump_buffer(stderr, conn); | 2323 // th_conn_dump_buffer(stderr, conn); |
2324 int result = nn_parse_protocol(conn); | 2324 int result = nn_parse_protocol(conn); |
2325 if (result == 0) | 2325 if (result == 0) |
2332 // Retry if possible | 2332 // Retry if possible |
2333 if (--retries > 0) | 2333 if (--retries > 0) |
2334 goto packet_retry; | 2334 goto packet_retry; |
2335 | 2335 |
2336 // Couldn't handle the message for some reason | 2336 // Couldn't handle the message for some reason |
2337 printMsg(currWin, "Could not handle: %s\n", conn->ptr); | 2337 printMsg(currWin, "Could not handle: %s\n", conn->base.ptr); |
2338 th_conn_buf_skip(conn, strlen(conn->ptr) + 1); | 2338 th_conn_buf_skip(conn, strlen(conn->base.ptr) + 1); |
2339 } | 2339 } |
2340 else | 2340 else |
2341 editState.isError = TRUE; | 2341 editState.isError = TRUE; |
2342 } | 2342 } |
2343 } | 2343 } |