1 /* libcyr_cfg.h -- configuration interface to libcyrus 2 * 3 * Copyright (c) 1994-2008 Carnegie Mellon University. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the 15 * distribution. 16 * 17 * 3. The name "Carnegie Mellon University" must not be used to 18 * endorse or promote products derived from this software without 19 * prior written permission. For permission or any legal 20 * details, please contact 21 * Carnegie Mellon University 22 * Center for Technology Transfer and Enterprise Creation 23 * 4615 Forbes Avenue 24 * Suite 302 25 * Pittsburgh, PA 15213 26 * (412) 268-7393, fax: (412) 268-7395 27 * innovation@andrew.cmu.edu 28 * 29 * 4. Redistributions of any form whatsoever must retain the following 30 * acknowledgment: 31 * "This product includes software developed by Computing Services 32 * at Carnegie Mellon University (http://www.cmu.edu/computing/)." 33 * 34 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO 35 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 36 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE 37 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 38 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 39 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 40 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 41 */ 42 43 #ifndef INCLUDED_LIBCYR_CFG_H 44 #define INCLUDED_LIBCYR_CFG_H 45 46 #include <stdio.h> 47 #include <string.h> 48 #include <stdlib.h> 49 #include <sys/types.h> 50 #include <sys/stat.h> 51 52 /* This is basically a simplified version of the configuration system 53 * that is used for the application level of Cyrus IMAPd */ 54 55 enum cyrus_opttype { 56 CYRUS_OPT_NOTOPT, 57 CYRUS_OPT_STRING, 58 CYRUS_OPT_INT, 59 CYRUS_OPT_SWITCH 60 }; 61 62 enum cyrus_opt { 63 64 CYRUSOPT_ZERO = 0, 65 66 /* Use unix groups with auth_unix? (ON) */ 67 CYRUSOPT_AUTH_UNIX_GROUP_ENABLE, 68 /* Lowercase usernames? (OFF) */ 69 CYRUSOPT_USERNAME_TOLOWER, 70 /* Don't fsync() the skiplist backend (OFF) */ 71 CYRUSOPT_SKIPLIST_UNSAFE, 72 /* Temporary Storage Directory ("/tmp") */ 73 CYRUSOPT_TEMP_PATH, 74 /* PTS Cache Timeout */ 75 CYRUSOPT_PTS_CACHE_TIMEOUT, 76 /* IMAPd config directory */ 77 CYRUSOPT_CONFIG_DIR, 78 /* CyrusDB INIT flags */ 79 CYRUSOPT_DB_INIT_FLAGS, 80 /* Full directory hashing (OFF) */ 81 CYRUSOPT_FULLDIRHASH, 82 /* Database for use by AUTH_PTS */ 83 CYRUSOPT_PTSCACHE_DB, 84 /* Path to database for use by AUTH_PTS */ 85 CYRUSOPT_PTSCACHE_DB_PATH, 86 /* ptloader socket for use by AUTH_PTS */ 87 CYRUSOPT_PTLOADER_SOCK, 88 /* Virtual Domains (OFF) */ 89 CYRUSOPT_VIRTDOMAINS, 90 /* authorization mechanism (unix) */ 91 CYRUSOPT_AUTH_MECH, 92 /* BDB max locks (50000) */ 93 CYRUSOPT_DELETERIGHT, 94 /* SQL database */ 95 CYRUSOPT_SQL_DATABASE, 96 /* SQL engine */ 97 CYRUSOPT_SQL_ENGINE, 98 /* SQL hostname(s) ("") */ 99 CYRUSOPT_SQL_HOSTNAMES, 100 /* SQL username */ 101 CYRUSOPT_SQL_USER, 102 /* SQL password */ 103 CYRUSOPT_SQL_PASSWD, 104 /* Secure SQL connection (OFF) */ 105 CYRUSOPT_SQL_USESSL, 106 /* Checkpoint after every recovery (OFF) */ 107 CYRUSOPT_SKIPLIST_ALWAYS_CHECKPOINT, 108 109 CYRUSOPT_LAST 110 111 }; 112 113 union cyrus_config_value { 114 const char *s; /* string */ 115 long i; /* int */ 116 long b; /* switch */ 117 }; 118 119 struct cyrusopt_s { 120 const enum cyrus_opt opt; 121 union cyrus_config_value val; 122 const enum cyrus_opttype t; 123 }; 124 125 /* these will assert() if they're called on the wrong type of 126 option (imapopt.c) */ 127 extern const char *libcyrus_config_getstring(enum cyrus_opt opt); 128 extern int libcyrus_config_getint(enum cyrus_opt opt); 129 extern int libcyrus_config_getswitch(enum cyrus_opt opt); 130 131 void libcyrus_config_setstring(enum cyrus_opt opt, const char *val); 132 void libcyrus_config_setint(enum cyrus_opt opt, int val); 133 void libcyrus_config_setswitch(enum cyrus_opt opt, int val); 134 135 /* Start/Stop the Library */ 136 /* Should be done AFTER setting configuration options */ 137 void libcyrus_init(void); 138 void libcyrus_done(void); 139 140 #endif 141