libpurple/protocols/zephyr/Zinternal.c

branch
release-2.x.y
changeset 43153
2e4624a59df5
parent 38213
fe644fbe41c9
equal deleted inserted replaced
43152:9d1565e94617 43153:2e4624a59df5
69 /* Find or insert uid in the old uids buffer. The buffer is a sorted 69 /* Find or insert uid in the old uids buffer. The buffer is a sorted
70 * circular queue. We make the assumption that most packets arrive in 70 * circular queue. We make the assumption that most packets arrive in
71 * order, so we can usually search for a uid or insert it into the buffer 71 * order, so we can usually search for a uid or insert it into the buffer
72 * by looking back just a few entries from the end. Since this code is 72 * by looking back just a few entries from the end. Since this code is
73 * only executed by the client, the implementation isn't microoptimized. */ 73 * only executed by the client, the implementation isn't microoptimized. */
74 static int find_or_insert_uid(uid, kind) 74 static int
75 ZUnique_Id_t *uid; 75 find_or_insert_uid(ZUnique_Id_t *uid, ZNotice_Kind_t kind)
76 ZNotice_Kind_t kind;
77 { 76 {
78 static struct _filter { 77 static struct _filter {
79 ZUnique_Id_t uid; 78 ZUnique_Id_t uid;
80 ZNotice_Kind_t kind; 79 ZNotice_Kind_t kind;
81 time_t t; 80 time_t t;
170 } 169 }
171 170
172 171
173 /* Read any available packets and enqueue them */ 172 /* Read any available packets and enqueue them */
174 173
175 Code_t Z_ReadEnqueue() 174 Code_t
175 Z_ReadEnqueue(void)
176 { 176 {
177 Code_t retval; 177 Code_t retval;
178 178
179 if (ZGetFD() < 0) 179 if (ZGetFD() < 0)
180 return (ZERR_NOPORT); 180 return (ZERR_NOPORT);
220 * 220 *
221 * This routine does NOT guarantee a complete packet will be ready when it 221 * This routine does NOT guarantee a complete packet will be ready when it
222 * returns. 222 * returns.
223 */ 223 */
224 224
225 Code_t Z_ReadWait() 225 Code_t
226 Z_ReadWait(void)
226 { 227 {
227 register struct _Z_InputQ *qptr; 228 register struct _Z_InputQ *qptr;
228 ZNotice_t notice; 229 ZNotice_t notice;
229 ZPacket_t packet; 230 ZPacket_t packet;
230 struct sockaddr_in olddest, from; 231 struct sockaddr_in olddest, from;
468 } 469 }
469 470
470 471
471 /* Fragment management routines - compliments, more or less, of RFC815 */ 472 /* Fragment management routines - compliments, more or less, of RFC815 */
472 473
473 Code_t Z_AddNoticeToEntry(qptr, notice, part) 474 Code_t
474 struct _Z_InputQ *qptr; 475 Z_AddNoticeToEntry(struct _Z_InputQ *qptr, ZNotice_t *notice, int part)
475 ZNotice_t *notice;
476 int part;
477 { 476 {
478 int last, oldfirst, oldlast; 477 int last, oldfirst, oldlast;
479 struct _Z_Hole *hole, *lasthole; 478 struct _Z_Hole *hole, *lasthole;
480 struct timeval tv; 479 struct timeval tv;
481 480
585 } 584 }
586 585
587 return (ZERR_NONE); 586 return (ZERR_NONE);
588 } 587 }
589 588
590 Code_t Z_FormatHeader(notice, buffer, buffer_len, len, cert_routine) 589 Code_t
591 ZNotice_t *notice; 590 Z_FormatHeader(ZNotice_t *notice, char *buffer, int buffer_len, int *len,
592 char *buffer; 591 Z_AuthProc cert_routine)
593 int buffer_len;
594 int *len;
595 Z_AuthProc cert_routine;
596 { 592 {
597 Code_t retval; 593 Code_t retval;
598 static char version[BUFSIZ]; /* default init should be all \0 */ 594 static char version[BUFSIZ]; /* default init should be all \0 */
599 struct sockaddr_in name; 595 struct sockaddr_in name;
600 socklen_t namelen = sizeof(name); 596 socklen_t namelen = sizeof(name);
630 notice->z_version = version; 626 notice->z_version = version;
631 627
632 return Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine); 628 return Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine);
633 } 629 }
634 630
635 Code_t Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine) 631 Code_t
636 ZNotice_t *notice; 632 Z_FormatAuthHeader(ZNotice_t *notice, char *buffer, int buffer_len, int *len,
637 char *buffer; 633 Z_AuthProc cert_routine)
638 int buffer_len;
639 int *len;
640 Z_AuthProc cert_routine;
641 { 634 {
642 if (!cert_routine) { 635 if (!cert_routine) {
643 notice->z_auth = 0; 636 notice->z_auth = 0;
644 notice->z_authent_len = 0; 637 notice->z_authent_len = 0;
645 notice->z_ascii_authent = ""; 638 notice->z_ascii_authent = "";
649 } 642 }
650 643
651 return ((*cert_routine)(notice, buffer, buffer_len, len)); 644 return ((*cert_routine)(notice, buffer, buffer_len, len));
652 } 645 }
653 646
654 Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend) 647 Code_t
655 ZNotice_t *notice; 648 Z_FormatRawHeader(ZNotice_t *notice, char *buffer, gsize buffer_len, int *len,
656 char *buffer; 649 char **cstart, char **cend)
657 gsize buffer_len;
658 int *len;
659 char **cstart, **cend;
660 { 650 {
661 char newrecip[BUFSIZ]; 651 char newrecip[BUFSIZ];
662 char *ptr, *end; 652 char *ptr, *end;
663 int i; 653 int i;
664 654
779 *ptr += len; 769 *ptr += len;
780 770
781 return 0; 771 return 0;
782 } 772 }
783 773
784 struct _Z_InputQ *Z_GetFirstComplete() 774 struct _Z_InputQ *
775 Z_GetFirstComplete(void)
785 { 776 {
786 struct _Z_InputQ *qptr; 777 struct _Z_InputQ *qptr;
787 778
788 qptr = __Q_Head; 779 qptr = __Q_Head;
789 780
794 } 785 }
795 786
796 return ((struct _Z_InputQ *)0); 787 return ((struct _Z_InputQ *)0);
797 } 788 }
798 789
799 struct _Z_InputQ *Z_GetNextComplete(qptr) 790 struct _Z_InputQ *
800 struct _Z_InputQ *qptr; 791 Z_GetNextComplete(struct _Z_InputQ *qptr)
801 { 792 {
802 qptr = qptr->next; 793 qptr = qptr->next;
803 while (qptr) { 794 while (qptr) {
804 if (qptr->complete) 795 if (qptr->complete)
805 return (qptr); 796 return (qptr);
807 } 798 }
808 799
809 return ((struct _Z_InputQ *)0); 800 return ((struct _Z_InputQ *)0);
810 } 801 }
811 802
812 void Z_RemQueue(qptr) 803 void
813 struct _Z_InputQ *qptr; 804 Z_RemQueue(struct _Z_InputQ *qptr)
814 { 805 {
815 struct _Z_Hole *hole, *nexthole; 806 struct _Z_Hole *hole, *nexthole;
816 807
817 if (qptr->complete) 808 if (qptr->complete)
818 __Q_CompleteLength--; 809 __Q_CompleteLength--;
856 qptr->next->prev = qptr->prev; 847 qptr->next->prev = qptr->prev;
857 free ((char *)qptr); 848 free ((char *)qptr);
858 return; 849 return;
859 } 850 }
860 851
861 Code_t Z_SendFragmentedNotice(notice, len, cert_func, send_func) 852 Code_t
862 ZNotice_t *notice; 853 Z_SendFragmentedNotice(ZNotice_t *notice, int len, Z_AuthProc cert_func,
863 int len; 854 Z_SendProc send_func)
864 Z_AuthProc cert_func;
865 Z_SendProc send_func;
866 { 855 {
867 ZNotice_t partnotice; 856 ZNotice_t partnotice;
868 ZPacket_t buffer; 857 ZPacket_t buffer;
869 char multi[64]; 858 char multi[64];
870 int offset, hdrsize, fragsize, ret_len, message_len, waitforack; 859 int offset, hdrsize, fragsize, ret_len, message_len, waitforack;
912 901
913 return (ZERR_NONE); 902 return (ZERR_NONE);
914 } 903 }
915 904
916 /*ARGSUSED*/ 905 /*ARGSUSED*/
917 Code_t Z_XmitFragment(notice, buf, len, wait) 906 Code_t
918 ZNotice_t *notice; 907 Z_XmitFragment(ZNotice_t *notice, char *buf, int len, int wait)
919 char *buf;
920 int len;
921 int wait;
922 { 908 {
923 return(ZSendPacket(buf, len, wait)); 909 return(ZSendPacket(buf, len, wait));
924 } 910 }
925 911
926 #ifdef Z_DEBUG 912 #ifdef Z_DEBUG
956 (*__Z_debug_print) (format, pvar, __Z_debug_print_closure); 942 (*__Z_debug_print) (format, pvar, __Z_debug_print_closure);
957 va_end (pvar); 943 va_end (pvar);
958 } 944 }
959 #endif 945 #endif
960 946
961 void Z_debug_stderr (format, args, closure) 947 void
962 const char *format; 948 Z_debug_stderr(const char *format, va_list args, void *closure)
963 va_list args;
964 void *closure;
965 { 949 {
966 #ifdef HAVE_VPRINTF 950 #ifdef HAVE_VPRINTF
967 vfprintf (stderr, format, args); 951 vfprintf (stderr, format, args);
968 #else 952 #else
969 _doprnt (format, args, stderr); 953 _doprnt (format, args, stderr);
970 #endif 954 #endif
971 putc ('\n', stderr); 955 putc ('\n', stderr);
972 } 956 }
973 957
974 #undef ZGetFD 958 #undef ZGetFD
975 int ZGetFD () { return __Zephyr_fd; } 959 int
960 ZGetFD(void)
961 {
962 return __Zephyr_fd;
963 }
976 964
977 #undef ZQLength 965 #undef ZQLength
978 int ZQLength () { return __Q_CompleteLength; } 966 int
967 ZQLength(void)
968 {
969 return __Q_CompleteLength;
970 }
979 971
980 #undef ZGetDestAddr 972 #undef ZGetDestAddr
981 struct sockaddr_in ZGetDestAddr () { return __HM_addr; } 973 struct sockaddr_in
974 ZGetDestAddr(void)
975 {
976 return __HM_addr;
977 }
982 978
983 #undef ZGetRealm 979 #undef ZGetRealm
984 Zconst char * ZGetRealm () { return __Zephyr_realm; } 980 Zconst char *
981 ZGetRealm(void)
982 {
983 return __Zephyr_realm;
984 }
985 985
986 #undef ZSetDebug 986 #undef ZSetDebug
987 void ZSetDebug(proc, arg) 987 void
988 void (*proc) __P((const char *, va_list, void *)); 988 ZSetDebug(void (*proc) __P((const char *, va_list, void *)), char *arg)
989 char *arg;
990 { 989 {
991 __Z_debug_print = proc; 990 __Z_debug_print = proc;
992 __Z_debug_print_closure = arg; 991 __Z_debug_print_closure = arg;
993 } 992 }
994 #endif /* Z_DEBUG */ 993 #endif /* Z_DEBUG */

mercurial