diff options
author | 1988-05-17 17:21:01 +0000 | |
---|---|---|
committer | 1988-05-17 17:21:01 +0000 | |
commit | 031ec0f258f152c1e20905b381aa7f5974db1f3d (patch) | |
tree | 1c15619ec8a5192e2d5095c6efde5e9a47ddc7ce /lib/ZLocateU.c | |
parent | 4d21b4b5da809cdf4499190a1e27bff679a90422 (diff) |
All sorts of changes for ver 0.2
Diffstat (limited to 'lib/ZLocateU.c')
-rw-r--r-- | lib/ZLocateU.c | 130 |
1 files changed, 66 insertions, 64 deletions
diff --git a/lib/ZLocateU.c b/lib/ZLocateU.c index 59a119b..57af9a5 100644 --- a/lib/ZLocateU.c +++ b/lib/ZLocateU.c @@ -20,84 +20,86 @@ static char rcsid_ZLocateUser_c[] = "$Header$"; #include <zephyr/zephyr_internal.h> -Code_t ZLocateUser(user,nlocs) - char *user; - int *nlocs; +Code_t ZLocateUser(user, nlocs) + char *user; + int *nlocs; { - int locate_pred(); + int i, retval; + ZNotice_t notice, retnotice; + char *ptr, *end; - int i,retval; - ZNotice_t notice,retnotice; - ZPacket_t buffer; - char *ptr,*end; - - retval = ZFlushLocations(); + retval = ZFlushLocations(); - if (retval != ZERR_NONE && retval != ZERR_NOLOCATIONS) - return (retval); + if (retval != ZERR_NONE && retval != ZERR_NOLOCATIONS) + return (retval); - notice.z_kind = ACKED; - notice.z_port = 0; - notice.z_class = LOCATE_CLASS; - notice.z_class_inst = user; - notice.z_opcode = LOCATE_LOCATE; - notice.z_sender = 0; - notice.z_recipient = ""; - notice.z_default_format = ""; - notice.z_message_len = 0; + notice.z_kind = ACKED; + notice.z_port = 0; + notice.z_class = LOCATE_CLASS; + notice.z_class_inst = user; + notice.z_opcode = LOCATE_LOCATE; + notice.z_sender = 0; + notice.z_recipient = ""; + notice.z_default_format = ""; + notice.z_message_len = 0; - if ((retval = ZSendNotice(¬ice,ZAUTH)) != ZERR_NONE) - return (retval); + if ((retval = ZSendNotice(¬ice, ZAUTH)) != ZERR_NONE) + return (retval); - if ((retval = ZIfNotice(buffer,sizeof buffer,&retnotice,NULL, - ZCompareUIDPred,(char *)¬ice.z_uid)) != - ZERR_NONE) - return (retval); + if ((retval = ZIfNotice(&retnotice, NULL, ZCompareUIDPred, + (char *)¬ice.z_uid)) != ZERR_NONE) + return (retval); - if (retnotice.z_kind == SERVNAK) - return (ZERR_SERVNAK); + if (retnotice.z_kind == SERVNAK) { + ZFreeNotice(&retnotice); + return (ZERR_SERVNAK); + } - if (retnotice.z_kind != SERVACK) - return (ZERR_INTERNAL); + if (retnotice.z_kind != SERVACK) { + ZFreeNotice(&retnotice); + return (ZERR_INTERNAL); + } - end = retnotice.z_message+retnotice.z_message_len; + end = retnotice.z_message+retnotice.z_message_len; - __locate_num = 0; + __locate_num = 0; - for (ptr=retnotice.z_message;ptr<end;ptr++) - if (!*ptr) - __locate_num++; + for (ptr=retnotice.z_message;ptr<end;ptr++) + if (!*ptr) + __locate_num++; - __locate_num /= 3; + __locate_num /= 3; - __locate_list = (ZLocations_t *)malloc((unsigned)__locate_num* - sizeof(ZLocations_t)); - if (!__locate_list) - return (ENOMEM); + __locate_list = (ZLocations_t *)malloc((unsigned)__locate_num* + sizeof(ZLocations_t)); + if (!__locate_list) + return (ENOMEM); - for (ptr=retnotice.z_message,i=0;i<__locate_num;i++) { - __locate_list[i].host = (char *)malloc((unsigned)strlen(ptr)+ - 1); - if (!__locate_list[i].host) - return (ENOMEM); - (void) strcpy(__locate_list[i].host,ptr); - ptr += strlen(ptr)+1; - __locate_list[i].time = (char *)malloc((unsigned)strlen(ptr)+ - 1); - if (!__locate_list[i].time) - return (ENOMEM); - (void) strcpy(__locate_list[i].time,ptr); - ptr += strlen(ptr)+1; - __locate_list[i].tty = (char *)malloc((unsigned)strlen(ptr)+ - 1); - if (!__locate_list[i].tty) - return (ENOMEM); - (void) strcpy(__locate_list[i].tty,ptr); - ptr += strlen(ptr)+1; - } + for (ptr=retnotice.z_message, i=0;i<__locate_num;i++) { + __locate_list[i].host = (char *)malloc((unsigned)strlen(ptr)+ + 1); + if (!__locate_list[i].host) + return (ENOMEM); + (void) strcpy(__locate_list[i].host, ptr); + ptr += strlen(ptr)+1; + __locate_list[i].time = (char *)malloc((unsigned)strlen(ptr)+ + 1); + if (!__locate_list[i].time) + return (ENOMEM); + (void) strcpy(__locate_list[i].time, ptr); + ptr += strlen(ptr)+1; + __locate_list[i].tty = (char *)malloc((unsigned)strlen(ptr)+ + 1); + if (!__locate_list[i].tty) + return (ENOMEM); + (void) strcpy(__locate_list[i].tty, ptr); + ptr += strlen(ptr)+1; + } - __locate_next = 0; - *nlocs = __locate_num; + ZFreeNotice(&retnotice); + + __locate_next = 0; + *nlocs = __locate_num; - return (ZERR_NONE); + return (ZERR_NONE); } |