| 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; |
| 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 |
| 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; |
| 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 */ |