]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/lib/ZNewLocU.c
r4254@bucket (orig r244): kcr | 2008-01-20 14:40:42 -0500
[1ts-debian.git] / zephyr / lib / ZNewLocU.c
1 /* This file is part of the Project Athena Zephyr Notification System.
2  * It contains source for the ZNewLocateUser function.
3  *
4  *      Created by:     Robert French
5  *
6  *      $Id$
7  *
8  *      Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology.
9  *      For copying and distribution information, see the file
10  *      "mit-copyright.h". 
11  */
12
13 #include <internal.h>
14
15 #ifndef lint
16 static const char rcsid_ZNewLocateUser_c[] =
17     "$Id$";
18 #endif
19
20 Code_t
21 ZLocateUser(char *user,
22             int *nlocs,
23             Z_AuthProc auth)
24 {
25     Code_t retval;
26     ZNotice_t notice;
27     ZAsyncLocateData_t zald;
28
29     (void) ZFlushLocations();   /* ZFlushLocations never fails (the library
30                                    is allowed to know this). */
31
32     if ((retval = ZRequestLocations(user, &zald, UNACKED, auth)) != ZERR_NONE)
33         return(retval);
34
35     retval = Z_WaitForNotice (&notice, ZCompareALDPred, &zald, SRV_TIMEOUT);
36     if (retval == ZERR_NONOTICE)
37         return ETIMEDOUT;
38     if (retval != ZERR_NONE)
39         return retval;
40
41     if ((retval = ZParseLocations(&notice, &zald, nlocs, NULL)) != ZERR_NONE) {
42         ZFreeNotice(&notice);
43         return(retval);
44     }
45
46     ZFreeNotice(&notice);
47     ZFreeALD(&zald);
48     return(ZERR_NONE);
49 }