1 /* 2 * wzdftpd - a modular and cool ftp server 3 * Copyright (C) 2002-2004 Pierre Chifflier 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * As a special exemption, Pierre Chifflier 20 * and other respective copyright holders give permission to link this program 21 * with OpenSSL, and distribute the resulting executable, without including 22 * the source code for OpenSSL in the source distribution. 23 */ 24 25 #ifndef __WZD_VARS__ 26 #define __WZD_VARS__ 27 28 /** \file wzd_vars.h 29 * \brief Get or change values from server variables 30 * 31 * \addtogroup libwzd_core 32 * @{ 33 */ 34 35 /** \brief Shared variables between connections 36 * 37 * Theses variables are not really shared, since classic memory is 38 * implicitely shared between threads. 39 */ 40 struct wzd_shm_vars_t { 41 char *key; 42 void * data; 43 unsigned long datalength; 44 45 struct wzd_shm_vars_t * next_var; 46 }; 47 48 /** \brief Get the value of a server variable 49 * \returns 0 if ok, 1 if an error occured 50 */ 51 int vars_get(const char *varname, void *data, unsigned int datalength, wzd_config_t * config); 52 53 /** \brief Change value of server variable 54 * \returns 0 if ok, 1 if an error occured 55 */ 56 int vars_set(const char *varname, const void *data, unsigned int datalength, wzd_config_t * config); 57 58 /** \brief Get the value of a user variable 59 * \returns 0 if ok, 1 if an error occured 60 */ 61 int vars_user_get(const char *username, const char *varname, void *data, unsigned int datalength, wzd_config_t * config); 62 63 /** \brief Change value of user variable 64 * \param username the name of the user 65 * \param varname the name of the variable to change 66 * \param data the new value 67 * \param datalength size of data 68 * \param config the running server config 69 * \returns 0 if ok, 1 if an error occured 70 */ 71 int vars_user_set(const char *username, const char *varname, const void *data, unsigned int datalength, wzd_config_t * config); 72 73 /** \brief Create a new user 74 * \returns 0 if ok, 1 if an error occured 75 */ 76 int vars_user_new(const char *username, const char *pass, const char *groupname, wzd_config_t * config); 77 78 /** \brief Add an authorized ip to user 79 * \return 0 if ok 80 */ 81 int vars_user_addip(const char *username, const char *ip, wzd_config_t *config); 82 83 /** \brief Remove an authorized ip to user 84 * \param username the user s name 85 * \param ip either the slot number or the ip 86 * \param config the running server config 87 * \returns 0 if ok 88 */ 89 int vars_user_delip(const char *username, const char *ip, wzd_config_t *config); 90 91 /** \brief Get the value of a group variable 92 * \returns 0 if ok, 1 if an error occured 93 */ 94 int vars_group_get(const char *groupname, const char *varname, void *data, unsigned int datalength, wzd_config_t * config); 95 96 /** \brief Change value of group variable 97 * \param groupname the name of the group 98 * \param varname the name of the variable to change 99 * \param data the new value 100 * \param datalength size of data 101 * \param config the running server config 102 * \returns 0 if ok, 1 if an error occured 103 */ 104 int vars_group_set(const char *groupname, const char *varname, const void *data, unsigned int datalength, wzd_config_t * config); 105 106 /** create a new group 107 * @returns 0 if ok, 1 if an error occured 108 */ 109 int vars_group_new(const char *groupname, wzd_config_t * config); 110 111 112 void vars_shm_init(void); 113 void vars_shm_free(void); 114 115 /* finds shm entry corresponding to 'varname' 116 * @returns a pointer to the struct or NULL 117 */ 118 struct wzd_shm_vars_t * vars_shm_find(const char *varname, wzd_config_t * config); 119 120 /** fills data with varname content, max size: datalength 121 * @returns 0 if ok, 1 if an error occured 122 */ 123 int vars_shm_get(const char *varname, void *data, unsigned int datalength, wzd_config_t * config); 124 125 /** change varname with data contents size of data is datalength 126 * @returns 0 if ok, 1 if an error occured 127 */ 128 int vars_shm_set(const char *varname, void *data, unsigned int datalength, wzd_config_t * config); 129 130 /** @} */ 131 132 #endif /* __WZD_VARS__ */ 133