xorp

homedir.h

00001 #ifndef homedir_h
00002 #define homedir_h
00003 
00004 /*
00005  * Copyright (c) 2000, 2001 by Martin C. Shepherd.
00006  * 
00007  * All rights reserved.
00008  * 
00009  * Permission is hereby granted, free of charge, to any person obtaining a
00010  * copy of this software and associated documentation files (the
00011  * "Software"), to deal in the Software without restriction, including
00012  * without limitation the rights to use, copy, modify, merge, publish,
00013  * distribute, and/or sell copies of the Software, and to permit persons
00014  * to whom the Software is furnished to do so, provided that the above
00015  * copyright notice(s) and this permission notice appear in all copies of
00016  * the Software and that both the above copyright notice(s) and this
00017  * permission notice appear in supporting documentation.
00018  * 
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00020  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00021  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
00022  * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
00023  * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
00024  * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
00025  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
00026  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
00027  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00028  * 
00029  * Except as contained in this notice, the name of a copyright holder
00030  * shall not be used in advertising or otherwise to promote the sale, use
00031  * or other dealings in this Software without prior written authorization
00032  * of the copyright holder.
00033  */
00034 
00035 typedef struct HomeDir HomeDir;
00036 
00037 /*
00038  * The following constructor and destructor functions create and
00039  * delete the resources needed to look up home directories.
00040  */
00041 HomeDir *_new_HomeDir(void);
00042 HomeDir *_del_HomeDir(HomeDir *home);
00043 
00044 /*
00045  * Return the home directory of a specified user, or NULL if unknown.
00046  */
00047 const char *_hd_lookup_home_dir(HomeDir *home, const char *user);
00048 
00049 /*
00050  * Get the description of the that occured when _hd_lookup_home_dir() was
00051  * last called.
00052  */
00053 const char *_hd_last_home_dir_error(HomeDir *home);
00054 
00055 /*
00056  * The _hd_scan_user_home_dirs() function calls a user-provided function
00057  * for each username known by the system, passing the function both
00058  * the name and the home directory of the user.
00059  *
00060  * The following macro can be used to declare both pointers and
00061  * prototypes for the callback functions. The 'data' argument is
00062  * a copy of the 'data' argument passed to _hd_scan_user_home_dirs()
00063  * and is intended for the user of _hd_scan_user_home_dirs() to use
00064  * to pass anonymous context data to the callback function.
00065  * The username and home directories are passed to the callback function
00066  * in the *usrnam and *homedir arguments respectively.
00067  * To abort the scan, and have _hd_scan_user_home_dirs() return 1, the
00068  * callback function can return 1. A description of up to maxerr
00069  * characters before the terminating '\0', can be written to errmsg[].
00070  * This can then be examined by calling _hd_last_home_dir_error().
00071  * To indicate success and continue the scan, the callback function
00072  * should return 0. _hd_scan_user_home_dirs() returns 0 on successful
00073  * completion of the scan, or 1 if an error occurred or a call to the
00074  * callback function returned 1.
00075  */
00076 #define HOME_DIR_FN(fn) int (fn)(void *data, const char *usrnam, const char *homedir, char *errmsg, int maxerr)
00077 
00078 int _hd_scan_user_home_dirs(HomeDir *home, void *data,
00079                 HOME_DIR_FN(*callback_fn));
00080 
00081 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations