8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libtecla / common / homedir.h
blob195259a3a076b7f0e35bc4fac9442c88715be252
1 #ifndef homedir_h
2 #define homedir_h
4 /*
5 * Copyright (c) 2000, 2001, 2002, 2003, 2004 by Martin C. Shepherd.
6 *
7 * All rights reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the
11 * "Software"), to deal in the Software without restriction, including
12 * without limitation the rights to use, copy, modify, merge, publish,
13 * distribute, and/or sell copies of the Software, and to permit persons
14 * to whom the Software is furnished to do so, provided that the above
15 * copyright notice(s) and this permission notice appear in all copies of
16 * the Software and that both the above copyright notice(s) and this
17 * permission notice appear in supporting documentation.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
22 * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
24 * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
25 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
26 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
27 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 * Except as contained in this notice, the name of a copyright holder
30 * shall not be used in advertising or otherwise to promote the sale, use
31 * or other dealings in this Software without prior written authorization
32 * of the copyright holder.
35 #pragma ident "%Z%%M% %I% %E% SMI"
37 typedef struct HomeDir HomeDir;
40 * The following constructor and destructor functions create and
41 * delete the resources needed to look up home directories.
43 HomeDir *_new_HomeDir(void);
44 HomeDir *_del_HomeDir(HomeDir *home);
47 * Return the home directory of a specified user, or NULL if unknown.
49 const char *_hd_lookup_home_dir(HomeDir *home, const char *user);
52 * Get the description of the that occured when _hd_lookup_home_dir() was
53 * last called.
55 const char *_hd_last_home_dir_error(HomeDir *home);
58 * The _hd_scan_user_home_dirs() function calls a user-provided function
59 * for each username known by the system, passing the function both
60 * the name and the home directory of the user.
62 * The following macro can be used to declare both pointers and
63 * prototypes for the callback functions. The 'data' argument is
64 * a copy of the 'data' argument passed to _hd_scan_user_home_dirs()
65 * and is intended for the user of _hd_scan_user_home_dirs() to use
66 * to pass anonymous context data to the callback function.
67 * The username and home directories are passed to the callback function
68 * in the *usrnam and *homedir arguments respectively.
69 * To abort the scan, and have _hd_scan_user_home_dirs() return 1, the
70 * callback function can return 1. A description of up to maxerr
71 * characters before the terminating '\0', can be written to errmsg[].
72 * This can then be examined by calling _hd_last_home_dir_error().
73 * To indicate success and continue the scan, the callback function
74 * should return 0. _hd_scan_user_home_dirs() returns 0 on successful
75 * completion of the scan, or 1 if an error occurred or a call to the
76 * callback function returned 1.
78 #define HOME_DIR_FN(fn) int (fn)(void *data, const char *usrnam, const char *homedir, char *errmsg, int maxerr)
80 int _hd_scan_user_home_dirs(HomeDir *home, const char *prefix, void *data,
81 HOME_DIR_FN(*callback_fn));
83 #endif