[7d4fbcd] | 1 | #include "owl.h" |
---|
[f271129] | 2 | #include <stdio.h> |
---|
[7d4fbcd] | 3 | |
---|
[aa2f33b3] | 4 | #define OWLVAR_BOOL(name,default,summary,description) \ |
---|
[9efc154] | 5 | { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \ |
---|
[c1d9441] | 6 | NULL, NULL, NULL, NULL, NULL, NULL } |
---|
[7d4fbcd] | 7 | |
---|
[aa2f33b3] | 8 | #define OWLVAR_BOOL_FULL(name,default,summary,description,validate,set,get) \ |
---|
[9efc154] | 9 | { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \ |
---|
[c1d9441] | 10 | validate, set, NULL, get, NULL, NULL } |
---|
[7d4fbcd] | 11 | |
---|
[aa2f33b3] | 12 | #define OWLVAR_INT(name,default,summary,description) \ |
---|
[9efc154] | 13 | { g_strdup(name), OWL_VARIABLE_INT, NULL, default, "<int>", g_strdup(summary), g_strdup(description), NULL, \ |
---|
[7d4fbcd] | 14 | NULL, NULL, NULL, NULL, NULL, NULL } |
---|
| 15 | |
---|
[aa2f33b3] | 16 | #define OWLVAR_INT_FULL(name,default,summary,description,validset,validate,set,get) \ |
---|
[9efc154] | 17 | { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \ |
---|
[7d4fbcd] | 18 | validate, set, NULL, get, NULL, NULL } |
---|
| 19 | |
---|
[aa2f33b3] | 20 | #define OWLVAR_PATH(name,default,summary,description) \ |
---|
[9efc154] | 21 | { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<path>", g_strdup(summary), g_strdup(description), NULL, \ |
---|
[7d4fbcd] | 22 | NULL, NULL, NULL, NULL, NULL, NULL } |
---|
| 23 | |
---|
[aa2f33b3] | 24 | #define OWLVAR_STRING(name,default,summary,description) \ |
---|
[9efc154] | 25 | { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<string>", g_strdup(summary), g_strdup(description), NULL, \ |
---|
[7d4fbcd] | 26 | NULL, NULL, NULL, NULL, NULL, NULL } |
---|
| 27 | |
---|
[f203cad] | 28 | #define OWLVAR_STRING_FULL(name,default,validset,summary,description,validate,set,get) \ |
---|
[9efc154] | 29 | { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, validset, g_strdup(summary), g_strdup(description), NULL, \ |
---|
[c01e477] | 30 | validate, set, NULL, get, NULL, NULL } |
---|
| 31 | |
---|
[7d4fbcd] | 32 | /* enums are really integers, but where validset is a comma-separated |
---|
| 33 | * list of strings which can be specified. The tokens, starting at 0, |
---|
| 34 | * correspond to the values that may be specified. */ |
---|
[aa2f33b3] | 35 | #define OWLVAR_ENUM(name,default,summary,description,validset) \ |
---|
[9efc154] | 36 | { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \ |
---|
[7d4fbcd] | 37 | owl_variable_enum_validate, \ |
---|
| 38 | NULL, owl_variable_enum_set_fromstring, \ |
---|
| 39 | NULL, owl_variable_enum_get_tostring, \ |
---|
| 40 | NULL } |
---|
| 41 | |
---|
[aa2f33b3] | 42 | #define OWLVAR_ENUM_FULL(name,default,summary,description,validset,validate, set, get) \ |
---|
[9efc154] | 43 | { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \ |
---|
[217a43e] | 44 | validate, \ |
---|
| 45 | set, owl_variable_enum_set_fromstring, \ |
---|
| 46 | get, owl_variable_enum_get_tostring, \ |
---|
| 47 | NULL } |
---|
| 48 | |
---|
[9e86f6f] | 49 | int owl_variable_add_defaults(owl_vardict *vd) |
---|
| 50 | { |
---|
| 51 | owl_variable variables_to_init[] = { |
---|
[7d4fbcd] | 52 | |
---|
[5d365f6] | 53 | OWLVAR_STRING( "personalbell" /* %OwlVarStub */, "off", |
---|
[213a3eb] | 54 | "ring the terminal bell when personal messages are received", |
---|
[5d365f6] | 55 | "Can be set to 'on', 'off', or the name of a filter which\n" |
---|
| 56 | "messages need to match in order to ring the bell"), |
---|
[7d4fbcd] | 57 | |
---|
| 58 | OWLVAR_BOOL( "bell" /* %OwlVarStub */, 1, |
---|
[aa2f33b3] | 59 | "enable / disable the terminal bell", "" ), |
---|
[7d4fbcd] | 60 | |
---|
| 61 | OWLVAR_BOOL_FULL( "debug" /* %OwlVarStub */, OWL_DEBUG, |
---|
| 62 | "whether debugging is enabled", |
---|
[aa2f33b3] | 63 | "If set to 'on', debugging messages are logged to the\n" |
---|
| 64 | "file specified by the debugfile variable.\n", |
---|
[7d4fbcd] | 65 | NULL, owl_variable_debug_set, NULL), |
---|
| 66 | |
---|
| 67 | OWLVAR_BOOL( "startuplogin" /* %OwlVarStub */, 1, |
---|
[a16d7e5] | 68 | "send a login message when BarnOwl starts", "" ), |
---|
[7d4fbcd] | 69 | |
---|
| 70 | OWLVAR_BOOL( "shutdownlogout" /* %OwlVarStub */, 1, |
---|
[a16d7e5] | 71 | "send a logout message when BarnOwl exits", "" ), |
---|
[7d4fbcd] | 72 | |
---|
| 73 | OWLVAR_BOOL( "rxping" /* %OwlVarStub */, 0, |
---|
[aa2f33b3] | 74 | "display received pings", "" ), |
---|
[7d4fbcd] | 75 | |
---|
| 76 | OWLVAR_BOOL( "txping" /* %OwlVarStub */, 1, |
---|
[aa2f33b3] | 77 | "send pings", "" ), |
---|
[7d4fbcd] | 78 | |
---|
[73624b4] | 79 | OWLVAR_BOOL( "sepbar_disable" /* %OwlVarStub */, 0, |
---|
[451db9e] | 80 | "disable printing information in the separator bar", "" ), |
---|
[73624b4] | 81 | |
---|
[f9c43ae] | 82 | OWLVAR_BOOL( "smartstrip" /* %OwlVarStub */, 1, |
---|
| 83 | "strip kerberos instance for reply", ""), |
---|
| 84 | |
---|
[7e3e00a] | 85 | OWLVAR_BOOL( "newlinestrip" /* %OwlVarStub */, 1, |
---|
| 86 | "strip leading and trailing newlines", ""), |
---|
| 87 | |
---|
[7d4fbcd] | 88 | OWLVAR_BOOL( "displayoutgoing" /* %OwlVarStub */, 1, |
---|
[aa2f33b3] | 89 | "display outgoing messages", "" ), |
---|
[7d4fbcd] | 90 | |
---|
| 91 | OWLVAR_BOOL( "loginsubs" /* %OwlVarStub */, 1, |
---|
[aa2f33b3] | 92 | "load logins from .anyone on startup", "" ), |
---|
[7d4fbcd] | 93 | |
---|
| 94 | OWLVAR_BOOL( "logging" /* %OwlVarStub */, 0, |
---|
[aa2f33b3] | 95 | "turn personal logging on or off", |
---|
| 96 | "If this is set to on, personal messages are\n" |
---|
| 97 | "logged in the directory specified\n" |
---|
| 98 | "by the 'logpath' variable. The filename in that\n" |
---|
| 99 | "directory is derived from the sender of the message.\n" ), |
---|
[7d4fbcd] | 100 | |
---|
| 101 | OWLVAR_BOOL( "classlogging" /* %OwlVarStub */, 0, |
---|
[aa2f33b3] | 102 | "turn class logging on or off", |
---|
| 103 | "If this is set to on, class messages are\n" |
---|
| 104 | "logged in the directory specified\n" |
---|
| 105 | "by the 'classlogpath' variable.\n" |
---|
| 106 | "The filename in that directory is derived from\n" |
---|
| 107 | "the name of the class to which the message was sent.\n" ), |
---|
[7d4fbcd] | 108 | |
---|
[12c35df] | 109 | OWLVAR_ENUM( "loggingdirection" /* %OwlVarStub */, OWL_LOGGING_DIRECTION_BOTH, |
---|
[d544237] | 110 | "specifies which kind of messages should be logged", |
---|
[12c35df] | 111 | "Can be one of 'both', 'in', or 'out'. If 'in' is\n" |
---|
| 112 | "selected, only incoming messages are logged, if 'out'\n" |
---|
| 113 | "is selected only outgoing messages are logged. If 'both'\n" |
---|
| 114 | "is selected both incoming and outgoing messages are\n" |
---|
| 115 | "logged.", |
---|
| 116 | "both,in,out"), |
---|
| 117 | |
---|
[d126a19] | 118 | OWLVAR_BOOL_FULL( "colorztext" /* %OwlVarStub */, 1, |
---|
| 119 | "allow @color() in zephyrs to change color", |
---|
| 120 | NULL, NULL, owl_variable_colorztext_set, NULL), |
---|
[e1c4636] | 121 | |
---|
[c15bbfb] | 122 | OWLVAR_BOOL( "fancylines" /* %OwlVarStub */, 1, |
---|
| 123 | "Use 'nice' line drawing on the terminal.", |
---|
| 124 | "If turned off, dashes, pipes and pluses will be used\n" |
---|
| 125 | "to draw lines on the screen. Useful when the terminal\n" |
---|
| 126 | "is causing problems" ), |
---|
| 127 | |
---|
[d309eb3] | 128 | OWLVAR_BOOL( "zcrypt" /* %OwlVarStub */, 1, |
---|
| 129 | "Do automatic zcrypt processing", |
---|
| 130 | "" ), |
---|
| 131 | |
---|
[4357be8] | 132 | OWLVAR_BOOL_FULL( "pseudologins" /* %OwlVarStub */, 0, |
---|
| 133 | "Enable zephyr pseudo logins", |
---|
[a16d7e5] | 134 | "When this is enabled, BarnOwl will periodically check the zephyr\n" |
---|
[4357be8] | 135 | "location of users in your .anyone file. If a user is present\n" |
---|
| 136 | "but sent no login message, or a user is not present that sent no\n" |
---|
[d544237] | 137 | "logout message, a pseudo login or logout message will be created\n", |
---|
[4357be8] | 138 | NULL, owl_variable_pseudologins_set, NULL), |
---|
[5a95b69] | 139 | |
---|
[280ddc6] | 140 | OWLVAR_BOOL( "ignorelogins" /* %OwlVarStub */, 0, |
---|
| 141 | "Enable printing of login notifications", |
---|
[a16d7e5] | 142 | "When this is enabled, BarnOwl will print login and logout notifications\n" |
---|
| 143 | "for AIM, zephyr, or other protocols. If disabled BarnOwl will not print\n" |
---|
[3038d13] | 144 | "login or logout notifications.\n"), |
---|
[280ddc6] | 145 | |
---|
[15b34fd] | 146 | OWLVAR_STRING( "logfilter" /* %OwlVarStub */, "", |
---|
| 147 | "name of a filter controlling which messages to log", |
---|
| 148 | |
---|
| 149 | "If non empty, any messages matching the given filter will be logged.\n" |
---|
[d544237] | 150 | "This is a completely separate mechanism from the other logging\n" |
---|
[15b34fd] | 151 | "variables like logging, classlogging, loglogins, loggingdirection,\n" |
---|
| 152 | "etc. If you want this variable to control all logging, make sure\n" |
---|
| 153 | "all other logging variables are in their default state.\n"), |
---|
| 154 | |
---|
[e22f27c] | 155 | OWLVAR_BOOL( "loglogins" /* %OwlVarStub */, 0, |
---|
| 156 | "Enable logging of login notifications", |
---|
[a16d7e5] | 157 | "When this is enabled, BarnOwl will log login and logout notifications\n" |
---|
[30d0cf7] | 158 | "for AIM, zephyr, or other protocols. If disabled BarnOwl will not print\n" |
---|
[e22f27c] | 159 | "login or logout notifications.\n"), |
---|
| 160 | |
---|
[217a43e] | 161 | OWLVAR_ENUM_FULL( "disable-ctrl-d" /* %OwlVarStub:lockout_ctrld */, 1, |
---|
[aa2f33b3] | 162 | "don't send zephyrs on C-d", |
---|
[40de7394] | 163 | "If set to 'on', C-d won't send a zephyr from the edit\n" |
---|
| 164 | "window. If set to 'off', C-d will always send a zephyr\n" |
---|
[aa2f33b3] | 165 | "being composed in the edit window. If set to 'middle',\n" |
---|
| 166 | "C-d will only ever send a zephyr if the cursor is at\n" |
---|
| 167 | "the end of the message being composed.\n\n" |
---|
| 168 | "Note that this works by changing the C-d keybinding\n" |
---|
| 169 | "in the editmulti keymap.\n", |
---|
| 170 | "off,middle,on", |
---|
[7d4fbcd] | 171 | NULL, owl_variable_disable_ctrl_d_set, NULL), |
---|
| 172 | |
---|
| 173 | OWLVAR_PATH( "logpath" /* %OwlVarStub */, "~/zlog/people", |
---|
[aa2f33b3] | 174 | "path for logging personal zephyrs", |
---|
| 175 | "Specifies a directory which must exist.\n" |
---|
| 176 | "Files will be created in the directory for each sender.\n"), |
---|
[7d4fbcd] | 177 | |
---|
| 178 | OWLVAR_PATH( "classlogpath" /* %OwlVarStub:classlogpath */, "~/zlog/class", |
---|
[aa2f33b3] | 179 | "path for logging class zephyrs", |
---|
| 180 | "Specifies a directory which must exist.\n" |
---|
| 181 | "Files will be created in the directory for each class.\n"), |
---|
[7d4fbcd] | 182 | |
---|
| 183 | OWLVAR_PATH( "debug_file" /* %OwlVarStub */, OWL_DEBUG_FILE, |
---|
[aa2f33b3] | 184 | "path for logging debug messages when debugging is enabled", |
---|
[26ad412] | 185 | "This file will be logged to if 'debug' is set to 'on'.\n" |
---|
| 186 | "BarnOwl will append a dot and the current process's pid to the filename."), |
---|
[7d4fbcd] | 187 | |
---|
[ced25d1] | 188 | OWLVAR_PATH( "zsigproc" /* %OwlVarStub:zsigproc */, NULL, |
---|
[aa2f33b3] | 189 | "name of a program to run that will generate zsigs", |
---|
| 190 | "This program should produce a zsig on stdout when run.\n" |
---|
[81a96af] | 191 | "Note that it is important that this program not block.\n\n" |
---|
| 192 | "See the documentation for 'zsig' for more information about\n" |
---|
| 193 | "how the outgoing zsig is chosen." |
---|
| 194 | ), |
---|
[7d4fbcd] | 195 | |
---|
[700c712] | 196 | OWLVAR_PATH( "newmsgproc" /* %OwlVarStub:newmsgproc */, NULL, |
---|
| 197 | "name of a program to run when new messages are present", |
---|
[a16d7e5] | 198 | "The named program will be run when BarnOwl receives new\n" |
---|
[700c712] | 199 | "messages. It will not be run again until the first\n" |
---|
| 200 | "instance exits"), |
---|
| 201 | |
---|
[247cbc9] | 202 | OWLVAR_STRING( "zsender" /* %OwlVarStub */, "", |
---|
| 203 | "zephyr sender name", |
---|
| 204 | "Allows you to customize the outgoing username in\n" |
---|
| 205 | "zephyrs. If this is unset, it will use your Kerberos\n" |
---|
| 206 | "principal. Note that customizing the sender name will\n" |
---|
| 207 | "cause your zephyrs to be sent unauthenticated."), |
---|
| 208 | |
---|
[de3f641] | 209 | OWLVAR_STRING( "zsigfunc" /* %OwlVarStub */, "BarnOwl::default_zephyr_signature()", |
---|
| 210 | "zsig perl function", |
---|
| 211 | "Called every time you start a zephyrgram without an\n" |
---|
| 212 | "explicit zsig. The default setting implements the policy\n" |
---|
[b120bd3] | 213 | "described in the documentation for the 'zsig' variable.\n" |
---|
| 214 | "See also BarnOwl::random_zephyr_signature().\n"), |
---|
[de3f641] | 215 | |
---|
[7d4fbcd] | 216 | OWLVAR_STRING( "zsig" /* %OwlVarStub */, "", |
---|
[81a96af] | 217 | "zephyr signature", |
---|
| 218 | "The zsig to get on outgoing messages. If this variable is\n" |
---|
| 219 | "unset, 'zsigproc' will be run to generate a zsig. If that is\n" |
---|
| 220 | "also unset, the 'zwrite-signature' zephyr variable will be\n" |
---|
| 221 | "used instead.\n"), |
---|
[7d4fbcd] | 222 | |
---|
| 223 | OWLVAR_STRING( "appendtosepbar" /* %OwlVarStub */, "", |
---|
[aa2f33b3] | 224 | "string to append to the end of the sepbar", |
---|
| 225 | "The sepbar is the bar separating the top and bottom\n" |
---|
[a16d7e5] | 226 | "of the BarnOwl screen. Any string specified here will\n" |
---|
[aa2f33b3] | 227 | "be displayed on the right of the sepbar\n"), |
---|
[7d4fbcd] | 228 | |
---|
| 229 | OWLVAR_BOOL( "zaway" /* %OwlVarStub */, 0, |
---|
[aa2f33b3] | 230 | "turn zaway on or off", "" ), |
---|
[7d4fbcd] | 231 | |
---|
| 232 | OWLVAR_STRING( "zaway_msg" /* %OwlVarStub */, |
---|
| 233 | OWL_DEFAULT_ZAWAYMSG, |
---|
[aa2f33b3] | 234 | "zaway msg for responding to zephyrs when away", "" ), |
---|
[7d4fbcd] | 235 | |
---|
| 236 | OWLVAR_STRING( "zaway_msg_default" /* %OwlVarStub */, |
---|
| 237 | OWL_DEFAULT_ZAWAYMSG, |
---|
[aa2f33b3] | 238 | "default zaway message", "" ), |
---|
[7d4fbcd] | 239 | |
---|
[4b660cc] | 240 | OWLVAR_BOOL_FULL( "aaway" /* %OwlVarStub */, 0, |
---|
| 241 | "Set AIM away status", |
---|
| 242 | "", |
---|
| 243 | NULL, owl_variable_aaway_set, NULL), |
---|
| 244 | |
---|
| 245 | OWLVAR_STRING( "aaway_msg" /* %OwlVarStub */, |
---|
| 246 | OWL_DEFAULT_AAWAYMSG, |
---|
| 247 | "AIM away msg for responding when away", "" ), |
---|
| 248 | |
---|
| 249 | OWLVAR_STRING( "aaway_msg_default" /* %OwlVarStub */, |
---|
| 250 | OWL_DEFAULT_AAWAYMSG, |
---|
| 251 | "default AIM away message", "" ), |
---|
| 252 | |
---|
[7d4fbcd] | 253 | OWLVAR_STRING( "view_home" /* %OwlVarStub */, "all", |
---|
[aa2f33b3] | 254 | "home view to switch to after 'X' and 'V'", |
---|
| 255 | "SEE ALSO: view, filter\n" ), |
---|
[7d4fbcd] | 256 | |
---|
[ecd5dc5] | 257 | OWLVAR_STRING( "alert_filter" /* %OwlVarStub */, "none", |
---|
| 258 | "filter on which to trigger alert actions", |
---|
| 259 | "" ), |
---|
| 260 | |
---|
| 261 | OWLVAR_STRING( "alert_action" /* %OwlVarStub */, "nop", |
---|
[a16d7e5] | 262 | "BarnOwl command to execute for alert actions", |
---|
[ecd5dc5] | 263 | "" ), |
---|
| 264 | |
---|
[f203cad] | 265 | OWLVAR_STRING_FULL( "tty" /* %OwlVarStub */, "", "<string>", "tty name for zephyr location", "", |
---|
[c01e477] | 266 | NULL, owl_variable_tty_set, NULL), |
---|
[bd3f232] | 267 | |
---|
[bc14adc] | 268 | OWLVAR_STRING( "default_style" /* %OwlVarStub */, "default", |
---|
[c3ab155] | 269 | "name of the default formatting style", |
---|
[f1e629d] | 270 | "This sets the default message formatting style.\n" |
---|
| 271 | "Styles may be created with the 'style' command.\n" |
---|
| 272 | "Some built-in styles include:\n" |
---|
[a16d7e5] | 273 | " default - the default BarnOwl formatting\n" |
---|
[f1e629d] | 274 | " oneline - one line per-message\n" |
---|
| 275 | " perl - legacy perl interface\n" |
---|
| 276 | "\nSEE ALSO: style, show styles, view -s <style>\n" |
---|
| 277 | ), |
---|
| 278 | |
---|
[c3ab155] | 279 | |
---|
[d36f2cb] | 280 | OWLVAR_INT( "edit:maxfillcols" /* %OwlVarStub:edit_maxfillcols */, 70, |
---|
[4d9e4254] | 281 | "maximum number of columns for M-q (edit:fill-paragraph) to fill text to", |
---|
| 282 | "This specifies the maximum number of columns for M-q to fill text\n" |
---|
| 283 | "to. If set to 0, M-q will wrap to the width of the window, and\n" |
---|
| 284 | "values less than 0 disable M-q entirely.\n"), |
---|
[d36f2cb] | 285 | |
---|
[a4bbd80] | 286 | OWLVAR_INT( "edit:maxwrapcols" /* %OwlVarStub:edit_maxwrapcols */, 70, |
---|
[aa2f33b3] | 287 | "maximum number of columns for line-wrapping", |
---|
[4d9e4254] | 288 | "This specifies the maximum number of columns for\n" |
---|
| 289 | "auto-line-wrapping. If set to 0, text will be wrapped at the\n" |
---|
| 290 | "window width. Values less than 0 disable automatic wrapping.\n" |
---|
| 291 | "\n" |
---|
| 292 | "As a courtesy to recipients, it is recommended that outgoing\n" |
---|
| 293 | "Zephyr messages be no wider than 70 columns.\n"), |
---|
[d36f2cb] | 294 | |
---|
[1db061d] | 295 | OWLVAR_INT( "aim_ignorelogin_timer" /* %OwlVarStub */, 15, |
---|
[6a415e9] | 296 | "number of seconds after AIM login to ignore login messages", |
---|
| 297 | "This specifies the number of seconds to wait after an\n" |
---|
[d544237] | 298 | "AIM login before allowing the receipt of AIM login notifications.\n" |
---|
[1db061d] | 299 | "By default this is set to 15. If you would like to view login\n" |
---|
| 300 | "notifications of buddies as soon as you login, set it to 0 instead."), |
---|
[6a415e9] | 301 | |
---|
| 302 | |
---|
[7d4fbcd] | 303 | OWLVAR_INT_FULL( "typewinsize" /* %OwlVarStub:typwin_lines */, |
---|
| 304 | OWL_TYPWIN_SIZE, |
---|
[aa2f33b3] | 305 | "number of lines in the typing window", |
---|
| 306 | "This specifies the height of the window at the\n" |
---|
| 307 | "bottom of the screen where commands are entered\n" |
---|
| 308 | "and where messages are composed.\n", |
---|
| 309 | "int > 0", |
---|
[7d4fbcd] | 310 | owl_variable_int_validate_gt0, |
---|
| 311 | owl_variable_typewinsize_set, |
---|
| 312 | NULL /* use default for get */ |
---|
| 313 | ), |
---|
| 314 | |
---|
[da466e0] | 315 | OWLVAR_INT( "typewindelta" /* %OwlVarStub */, 0, |
---|
| 316 | "number of lines to add to the typing window when in use", |
---|
| 317 | "On small screens you may want the typing window to\n" |
---|
| 318 | "auto-hide when not entering a command or message.\n" |
---|
| 319 | "This variable is the number of lines to add to the\n" |
---|
| 320 | "typing window when it is in use; you can then set\n" |
---|
| 321 | "typewinsize to 1.\n\n" |
---|
| 322 | "This works a lot better with a non-default scrollmode;\n" |
---|
| 323 | "try :set scrollmode pagedcenter.\n"), |
---|
| 324 | |
---|
[aa2f33b3] | 325 | OWLVAR_ENUM( "scrollmode" /* %OwlVarStub */, OWL_SCROLLMODE_NORMAL, |
---|
| 326 | "how to scroll up and down", |
---|
| 327 | "This controls how the screen is scrolled as the\n" |
---|
| 328 | "cursor moves between messages being displayed.\n" |
---|
| 329 | "The following modes are supported:\n\n" |
---|
[a16d7e5] | 330 | " normal - This is the BarnOwl default. Scrolling happens\n" |
---|
[aa2f33b3] | 331 | " when it needs to, and an attempt is made to\n" |
---|
| 332 | " keep the current message roughly near\n" |
---|
| 333 | " the middle of the screen.\n" |
---|
| 334 | " top - The current message will always be the\n" |
---|
| 335 | " the top message displayed.\n" |
---|
| 336 | " neartop - The current message will be one down\n" |
---|
| 337 | " from the top message displayed,\n" |
---|
| 338 | " where possible.\n" |
---|
| 339 | " center - An attempt is made to keep the current\n" |
---|
| 340 | " message near the center of the screen.\n" |
---|
| 341 | " paged - The top message displayed only changes\n" |
---|
| 342 | " when user moves the cursor to the top\n" |
---|
| 343 | " or bottom of the screen. When it moves,\n" |
---|
| 344 | " the screen will be paged up or down and\n" |
---|
| 345 | " the cursor will be near the top or\n" |
---|
| 346 | " the bottom.\n" |
---|
| 347 | " pagedcenter - The top message displayed only changes\n" |
---|
| 348 | " when user moves the cursor to the top\n" |
---|
| 349 | " or bottom of the screen. When it moves,\n" |
---|
| 350 | " the screen will be paged up or down and\n" |
---|
| 351 | " the cursor will be near the center.\n", |
---|
| 352 | "normal,top,neartop,center,paged,pagedcenter" ), |
---|
| 353 | |
---|
[66e409c] | 354 | OWLVAR_BOOL( "narrow-related" /* %OwlVarStub:narrow_related */, 1, |
---|
| 355 | "Make smartnarrow use broader filters", |
---|
[8258ea5] | 356 | "Causes smartfilter to narrow to messages \"related\" to \n" |
---|
[66e409c] | 357 | "the current message, as well as ones to the same place.\n\n" |
---|
| 358 | "for Zephyr, this controls whether to narrow to e.g. class-help or\n" |
---|
| 359 | "class-help.d alone, or to related-class-help, which includes\n" |
---|
| 360 | "help, unhelp, help.d, etc.\n\nDefault is true (include unclasses, etc.).\n" ), |
---|
[ecd5dc5] | 361 | |
---|
[7d4fbcd] | 362 | OWLVAR_BOOL( "_followlast" /* %OwlVarStub */, 0, |
---|
[aa2f33b3] | 363 | "enable automatic following of the last zephyr", |
---|
| 364 | "If the cursor is at the last message, it will\n" |
---|
| 365 | "continue to follow the last message if this is set.\n" |
---|
| 366 | "Note that this is currently risky as you might accidentally\n" |
---|
| 367 | "delete a message right as it came in.\n" ), |
---|
[7d4fbcd] | 368 | |
---|
[f203cad] | 369 | OWLVAR_STRING_FULL( "default_exposure" /* %OwlVarStub */, "", |
---|
| 370 | "none,opstaff,realm-visible,realm-announced,net-visible,net-announced", |
---|
| 371 | "controls the persistent value for exposure", |
---|
| 372 | "The default exposure level corresponds to the Zephyr exposure value\n" |
---|
| 373 | "in ~/.zephyr.vars. Defaults to realm-visible if there is no value in\n" |
---|
| 374 | "~/.zephyr.vars.\n" |
---|
| 375 | "See the description of exposure for the values this can be.", |
---|
| 376 | NULL, owl_variable_default_exposure_set, owl_variable_default_exposure_get ), |
---|
| 377 | |
---|
| 378 | OWLVAR_STRING_FULL( "exposure" /* %OwlVarStub */, "", |
---|
| 379 | "none,opstaff,realm-visible,realm-announced,net-visible,net-announced", |
---|
| 380 | "controls who can zlocate you", |
---|
| 381 | "The exposure level, defaulting to the value of default_exposure,\n" |
---|
| 382 | "can be one of the following (from least exposure to widest exposure,\n" |
---|
| 383 | "as listed in zctl(1)):\n" |
---|
| 384 | "\n" |
---|
| 385 | " none - This completely disables Zephyr for the user. \n" |
---|
| 386 | " The user is not registered with Zephyr. No user\n" |
---|
| 387 | " location information is retained by Zephyr. No\n" |
---|
| 388 | " login or logout announcements will be sent. No\n" |
---|
| 389 | " subscriptions will be entered for the user, and\n" |
---|
| 390 | " no notices will be displayed by zwgc(1).\n" |
---|
| 391 | " opstaff - The user is registered with Zephyr. No login or\n" |
---|
| 392 | " logout announcements will be sent, and location\n" |
---|
| 393 | " information will only be visible to Operations\n" |
---|
| 394 | " staff. Default subscriptions and any additional\n" |
---|
| 395 | " personal subscriptions will be entered for the\n" |
---|
| 396 | " user.\n" |
---|
| 397 | " realm-visible - The user is registered with Zephyr. User\n" |
---|
| 398 | " location information is retained by Zephyr and\n" |
---|
| 399 | " made available only to users within the user’s\n" |
---|
| 400 | " Kerberos realm. No login or logout\n" |
---|
| 401 | " announcements will be sent. This is the system\n" |
---|
| 402 | " default. Default subscriptions and any\n" |
---|
| 403 | " additional personal subscriptions will be\n" |
---|
| 404 | " entered for the user.\n" |
---|
| 405 | " realm-announced - The user is registered with Zephyr. User\n" |
---|
| 406 | " location information is retained by Zephyr and\n" |
---|
| 407 | " made available only to users authenticated\n" |
---|
| 408 | " within the user’s Kerberos realm. Login and\n" |
---|
| 409 | " logout announcements will be sent, but only to\n" |
---|
| 410 | " users within the user’s Kerberos realm who have\n" |
---|
| 411 | " explicitly requested such via subscriptions. \n" |
---|
| 412 | " Default subscriptions and any additional\n" |
---|
| 413 | " personal subscriptions will be entered for the\n" |
---|
| 414 | " user.\n" |
---|
| 415 | " net-visible - The user is registered with Zephyr. User\n" |
---|
| 416 | " location information is retained by Zephyr and\n" |
---|
| 417 | " made available to any authenticated user who\n" |
---|
| 418 | " requests such. Login and logout announcements\n" |
---|
| 419 | " will be sent only to users within the user’s\n" |
---|
| 420 | " Kerberos realm who have explicitly requested\n" |
---|
| 421 | " such via subscriptions. Default subscriptions\n" |
---|
| 422 | " and any additional personal subscriptions will\n" |
---|
| 423 | " be entered for the user.\n" |
---|
| 424 | " net-announced - The user is registered with Zephyr. User\n" |
---|
| 425 | " location information is retained by Zephyr and\n" |
---|
| 426 | " made available to any authenticated user who\n" |
---|
| 427 | " requests such. Login and logout announcements\n" |
---|
| 428 | " will be sent to any user has requested such. \n" |
---|
| 429 | " Default subscriptions and any additional\n" |
---|
| 430 | " personal subscriptions will be entered for the\n" |
---|
| 431 | " user.\n", |
---|
| 432 | NULL, owl_variable_exposure_set, NULL /* use default for get */ ), |
---|
| 433 | |
---|
[7d4fbcd] | 434 | /* This MUST be last... */ |
---|
[aa2f33b3] | 435 | { NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, |
---|
| 436 | NULL, NULL, NULL, NULL, NULL, NULL } |
---|
[7d4fbcd] | 437 | |
---|
[9e86f6f] | 438 | }; |
---|
| 439 | |
---|
[9efc154] | 440 | int ret = owl_variable_dict_add_from_list(vd, variables_to_init); |
---|
| 441 | owl_variable *var; |
---|
| 442 | for (var = variables_to_init; var->name != NULL; var++) |
---|
| 443 | owl_variable_cleanup(var); |
---|
| 444 | return ret; |
---|
[9e86f6f] | 445 | } |
---|
[7d4fbcd] | 446 | |
---|
| 447 | /**************************************************************************/ |
---|
| 448 | /*********************** SPECIFIC TO VARIABLES ****************************/ |
---|
| 449 | /**************************************************************************/ |
---|
| 450 | |
---|
| 451 | |
---|
| 452 | /* commonly useful */ |
---|
| 453 | |
---|
[64735f0] | 454 | int owl_variable_int_validate_gt0(const owl_variable *v, const void *newval) |
---|
[4357be8] | 455 | { |
---|
[7d4fbcd] | 456 | if (newval == NULL) return(0); |
---|
[defe4a3] | 457 | else if (*(const int*)newval < 1) return(0); |
---|
[7d4fbcd] | 458 | else return (1); |
---|
| 459 | } |
---|
| 460 | |
---|
[64735f0] | 461 | int owl_variable_int_validate_positive(const owl_variable *v, const void *newval) |
---|
[4357be8] | 462 | { |
---|
[7d4fbcd] | 463 | if (newval == NULL) return(0); |
---|
[defe4a3] | 464 | else if (*(const int*)newval < 0) return(0); |
---|
[7d4fbcd] | 465 | else return (1); |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | /* typewinsize */ |
---|
[e19eb97] | 469 | int owl_variable_typewinsize_set(owl_variable *v, const void *newval) |
---|
[4357be8] | 470 | { |
---|
[7d4fbcd] | 471 | int rv; |
---|
| 472 | rv = owl_variable_int_set_default(v, newval); |
---|
[f6fae8d] | 473 | if (0 == rv) owl_mainpanel_layout_contents(&g.mainpanel); |
---|
[7d4fbcd] | 474 | return(rv); |
---|
| 475 | } |
---|
| 476 | |
---|
| 477 | /* debug (cache value in g->debug) */ |
---|
[e19eb97] | 478 | int owl_variable_debug_set(owl_variable *v, const void *newval) |
---|
[4357be8] | 479 | { |
---|
[defe4a3] | 480 | if (newval && (*(const int*)newval == 1 || *(const int*)newval == 0)) { |
---|
| 481 | g.debug = *(const int*)newval; |
---|
[7d4fbcd] | 482 | } |
---|
| 483 | return owl_variable_bool_set_default(v, newval); |
---|
[4b660cc] | 484 | } |
---|
| 485 | |
---|
| 486 | /* When 'aaway' is changed, need to notify the AIM server */ |
---|
[e19eb97] | 487 | int owl_variable_aaway_set(owl_variable *v, const void *newval) |
---|
[4357be8] | 488 | { |
---|
[4b660cc] | 489 | if (newval) { |
---|
[defe4a3] | 490 | if (*(const int*)newval == 1) { |
---|
[4b660cc] | 491 | owl_aim_set_awaymsg(owl_global_get_aaway_msg(&g)); |
---|
[defe4a3] | 492 | } else if (*(const int*)newval == 0) { |
---|
[4b660cc] | 493 | owl_aim_set_awaymsg(""); |
---|
| 494 | } |
---|
| 495 | } |
---|
| 496 | return owl_variable_bool_set_default(v, newval); |
---|
[7d4fbcd] | 497 | } |
---|
| 498 | |
---|
[d126a19] | 499 | int owl_variable_colorztext_set(owl_variable *v, const void *newval) |
---|
| 500 | { |
---|
| 501 | int ret = owl_variable_bool_set_default(v, newval); |
---|
| 502 | /* flush the format cache so that we see the update, but only if we're done initializing BarnOwl */ |
---|
| 503 | if (owl_global_get_msglist(&g) != NULL) |
---|
| 504 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
| 505 | if (owl_global_get_mainwin(&g) != NULL) { |
---|
| 506 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
| 507 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
| 508 | } |
---|
| 509 | return ret; |
---|
| 510 | } |
---|
| 511 | |
---|
[e19eb97] | 512 | int owl_variable_pseudologins_set(owl_variable *v, const void *newval) |
---|
[4357be8] | 513 | { |
---|
[72146c7] | 514 | static guint timer = 0; |
---|
[4357be8] | 515 | if (newval) { |
---|
[defe4a3] | 516 | if (*(const int*)newval == 1) { |
---|
[4357be8] | 517 | owl_function_zephyr_buddy_check(0); |
---|
[72146c7] | 518 | if (timer == 0) { |
---|
| 519 | timer = g_timeout_add_seconds(180, owl_zephyr_buddycheck_timer, NULL); |
---|
[3687413] | 520 | } |
---|
| 521 | } else { |
---|
[72146c7] | 522 | if (timer != 0) { |
---|
| 523 | g_source_remove(timer); |
---|
| 524 | timer = 0; |
---|
[3687413] | 525 | } |
---|
[4357be8] | 526 | } |
---|
| 527 | } |
---|
| 528 | return owl_variable_bool_set_default(v, newval); |
---|
| 529 | } |
---|
| 530 | |
---|
[7d4fbcd] | 531 | /* note that changing the value of this will clobber |
---|
| 532 | * any user setting of this */ |
---|
[e19eb97] | 533 | int owl_variable_disable_ctrl_d_set(owl_variable *v, const void *newval) |
---|
[4357be8] | 534 | { |
---|
[217a43e] | 535 | if (newval && !owl_context_is_startup(owl_global_get_context(&g))) { |
---|
[defe4a3] | 536 | if (*(const int*)newval == 2) { |
---|
[7d4fbcd] | 537 | owl_function_command_norv("bindkey editmulti C-d command edit:delete-next-char"); |
---|
[defe4a3] | 538 | } else if (*(const int*)newval == 1) { |
---|
[3b42640] | 539 | owl_function_command_norv("bindkey editmulti C-d command edit:done-or-delete"); |
---|
[7d4fbcd] | 540 | } else { |
---|
[3b42640] | 541 | owl_function_command_norv("bindkey editmulti C-d command edit:done"); |
---|
[7d4fbcd] | 542 | } |
---|
| 543 | } |
---|
[217a43e] | 544 | return owl_variable_int_set_default(v, newval); |
---|
[7d4fbcd] | 545 | } |
---|
| 546 | |
---|
[e19eb97] | 547 | int owl_variable_tty_set(owl_variable *v, const void *newval) |
---|
[4357be8] | 548 | { |
---|
[f54b07d] | 549 | owl_zephyr_set_locationinfo(g_get_host_name(), newval); |
---|
[c01e477] | 550 | return(owl_variable_string_set_default(v, newval)); |
---|
| 551 | } |
---|
| 552 | |
---|
[f203cad] | 553 | int owl_variable_default_exposure_set(owl_variable *v, const void *newval) |
---|
| 554 | { |
---|
| 555 | return owl_zephyr_set_default_exposure(newval); |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | const void *owl_variable_default_exposure_get(const owl_variable *v) |
---|
| 559 | { |
---|
| 560 | return owl_zephyr_get_default_exposure(); |
---|
| 561 | } |
---|
| 562 | |
---|
| 563 | int owl_variable_exposure_set(owl_variable *v, const void *newval) |
---|
| 564 | { |
---|
| 565 | int ret = owl_zephyr_set_exposure(newval); |
---|
| 566 | if (ret != 0) |
---|
| 567 | return ret; |
---|
| 568 | return owl_variable_string_set_default(v, owl_zephyr_normalize_exposure(newval)); |
---|
| 569 | } |
---|
[7d4fbcd] | 570 | |
---|
| 571 | /**************************************************************************/ |
---|
| 572 | /****************************** GENERAL ***********************************/ |
---|
| 573 | /**************************************************************************/ |
---|
| 574 | |
---|
| 575 | int owl_variable_dict_setup(owl_vardict *vd) { |
---|
[4c7c21f] | 576 | owl_dict_create(vd); |
---|
[9e86f6f] | 577 | return owl_variable_add_defaults(vd); |
---|
| 578 | } |
---|
| 579 | |
---|
| 580 | int owl_variable_dict_add_from_list(owl_vardict *vd, owl_variable *variables_to_init) |
---|
| 581 | { |
---|
| 582 | owl_variable *var, *cur; |
---|
[d536e72] | 583 | for (var = variables_to_init; var->name != NULL; var++) { |
---|
[96828e4] | 584 | cur = g_new(owl_variable, 1); |
---|
[66a8cd6] | 585 | *cur = *var; |
---|
[7d7326c] | 586 | /* strdup all the strings so we can delete them consistently. */ |
---|
[d4927a7] | 587 | cur->name = g_strdup(var->name); |
---|
| 588 | cur->summary = g_strdup(var->summary); |
---|
| 589 | cur->description = g_strdup(var->description); |
---|
[7d4fbcd] | 590 | switch (cur->type) { |
---|
| 591 | case OWL_VARIABLE_OTHER: |
---|
| 592 | cur->set_fn(cur, cur->pval_default); |
---|
| 593 | break; |
---|
| 594 | case OWL_VARIABLE_STRING: |
---|
| 595 | if (!cur->validate_fn) |
---|
| 596 | cur->validate_fn = owl_variable_string_validate_default; |
---|
| 597 | if (!cur->set_fn) |
---|
| 598 | cur->set_fn = owl_variable_string_set_default; |
---|
| 599 | if (!cur->set_fromstring_fn) |
---|
| 600 | cur->set_fromstring_fn = owl_variable_string_set_fromstring_default; |
---|
| 601 | if (!cur->get_fn) |
---|
| 602 | cur->get_fn = owl_variable_get_default; |
---|
| 603 | if (!cur->get_tostring_fn) |
---|
| 604 | cur->get_tostring_fn = owl_variable_string_get_tostring_default; |
---|
[bbd74a9] | 605 | if (!cur->delete_fn) |
---|
| 606 | cur->delete_fn = owl_variable_delete_default; |
---|
[ea68035] | 607 | cur->pval_default = g_strdup(var->pval_default); |
---|
[7d4fbcd] | 608 | cur->set_fn(cur, cur->pval_default); |
---|
| 609 | break; |
---|
| 610 | case OWL_VARIABLE_BOOL: |
---|
| 611 | if (!cur->validate_fn) |
---|
| 612 | cur->validate_fn = owl_variable_bool_validate_default; |
---|
| 613 | if (!cur->set_fn) |
---|
| 614 | cur->set_fn = owl_variable_bool_set_default; |
---|
| 615 | if (!cur->set_fromstring_fn) |
---|
| 616 | cur->set_fromstring_fn = owl_variable_bool_set_fromstring_default; |
---|
| 617 | if (!cur->get_fn) |
---|
| 618 | cur->get_fn = owl_variable_get_default; |
---|
| 619 | if (!cur->get_tostring_fn) |
---|
| 620 | cur->get_tostring_fn = owl_variable_bool_get_tostring_default; |
---|
[bbd74a9] | 621 | if (!cur->delete_fn) |
---|
| 622 | cur->delete_fn = owl_variable_delete_default; |
---|
[96828e4] | 623 | cur->val = g_new(int, 1); |
---|
[7d4fbcd] | 624 | cur->set_fn(cur, &cur->ival_default); |
---|
| 625 | break; |
---|
| 626 | case OWL_VARIABLE_INT: |
---|
| 627 | if (!cur->validate_fn) |
---|
| 628 | cur->validate_fn = owl_variable_int_validate_default; |
---|
| 629 | if (!cur->set_fn) |
---|
| 630 | cur->set_fn = owl_variable_int_set_default; |
---|
| 631 | if (!cur->set_fromstring_fn) |
---|
| 632 | cur->set_fromstring_fn = owl_variable_int_set_fromstring_default; |
---|
| 633 | if (!cur->get_fn) |
---|
| 634 | cur->get_fn = owl_variable_get_default; |
---|
| 635 | if (!cur->get_tostring_fn) |
---|
| 636 | cur->get_tostring_fn = owl_variable_int_get_tostring_default; |
---|
[bbd74a9] | 637 | if (!cur->delete_fn) |
---|
| 638 | cur->delete_fn = owl_variable_delete_default; |
---|
[96828e4] | 639 | cur->val = g_new(int, 1); |
---|
[7d4fbcd] | 640 | cur->set_fn(cur, &cur->ival_default); |
---|
| 641 | break; |
---|
| 642 | default: |
---|
| 643 | fprintf(stderr, "owl_variable_setup: invalid variable type\n"); |
---|
| 644 | return(-2); |
---|
| 645 | } |
---|
[4d86e06] | 646 | owl_dict_insert_element(vd, cur->name, cur, NULL); |
---|
[7d4fbcd] | 647 | } |
---|
| 648 | return 0; |
---|
| 649 | } |
---|
| 650 | |
---|
[a695a68] | 651 | void owl_variable_dict_add_variable(owl_vardict * vardict, |
---|
| 652 | owl_variable * var) { |
---|
[3b0edaa] | 653 | owl_dict_insert_element(vardict, var->name, var, (void (*)(void *))owl_variable_delete); |
---|
[a695a68] | 654 | } |
---|
| 655 | |
---|
[6829afc] | 656 | CALLER_OWN owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description) |
---|
[d427f08] | 657 | { |
---|
[96828e4] | 658 | owl_variable * var = g_new0(owl_variable, 1); |
---|
[d4927a7] | 659 | var->name = g_strdup(name); |
---|
| 660 | var->summary = g_strdup(summary); |
---|
| 661 | var->description = g_strdup(description); |
---|
[a695a68] | 662 | return var; |
---|
| 663 | } |
---|
| 664 | |
---|
[e19eb97] | 665 | void owl_variable_update(owl_variable *var, const char *summary, const char *desc) { |
---|
[3b8a563] | 666 | g_free(var->summary); |
---|
[d4927a7] | 667 | var->summary = g_strdup(summary); |
---|
[3b8a563] | 668 | g_free(var->description); |
---|
[d4927a7] | 669 | var->description = g_strdup(desc); |
---|
[d536e72] | 670 | } |
---|
| 671 | |
---|
[bc1d648] | 672 | void owl_variable_dict_newvar_string(owl_vardict *vd, const char *name, const char *summ, const char *desc, const char *initval) |
---|
| 673 | { |
---|
| 674 | owl_variable *old = owl_variable_get_var(vd, name); |
---|
[ca54fd6] | 675 | if (old && owl_variable_get_type(old) == OWL_VARIABLE_STRING) { |
---|
[d536e72] | 676 | owl_variable_update(old, summ, desc); |
---|
[3b8a563] | 677 | g_free(old->pval_default); |
---|
[d4927a7] | 678 | old->pval_default = g_strdup(initval); |
---|
[d536e72] | 679 | } else { |
---|
| 680 | owl_variable * var = owl_variable_newvar(name, summ, desc); |
---|
| 681 | var->type = OWL_VARIABLE_STRING; |
---|
[1dab38e] | 682 | var->validsettings = "<string>"; |
---|
[d4927a7] | 683 | var->pval_default = g_strdup(initval); |
---|
[d536e72] | 684 | var->set_fn = owl_variable_string_set_default; |
---|
| 685 | var->set_fromstring_fn = owl_variable_string_set_fromstring_default; |
---|
| 686 | var->get_fn = owl_variable_get_default; |
---|
| 687 | var->get_tostring_fn = owl_variable_string_get_tostring_default; |
---|
[bbd74a9] | 688 | var->delete_fn = owl_variable_delete_default; |
---|
[d536e72] | 689 | var->set_fn(var, initval); |
---|
| 690 | owl_variable_dict_add_variable(vd, var); |
---|
| 691 | } |
---|
[a695a68] | 692 | } |
---|
| 693 | |
---|
[bc1d648] | 694 | void owl_variable_dict_newvar_int(owl_vardict *vd, const char *name, const char *summ, const char *desc, int initval) |
---|
| 695 | { |
---|
| 696 | owl_variable *old = owl_variable_get_var(vd, name); |
---|
[ca54fd6] | 697 | if (old && owl_variable_get_type(old) == OWL_VARIABLE_INT) { |
---|
[d536e72] | 698 | owl_variable_update(old, summ, desc); |
---|
| 699 | old->ival_default = initval; |
---|
| 700 | } else { |
---|
| 701 | owl_variable * var = owl_variable_newvar(name, summ, desc); |
---|
| 702 | var->type = OWL_VARIABLE_INT; |
---|
[1dab38e] | 703 | var->validsettings = "<int>"; |
---|
[d536e72] | 704 | var->ival_default = initval; |
---|
| 705 | var->validate_fn = owl_variable_int_validate_default; |
---|
| 706 | var->set_fn = owl_variable_int_set_default; |
---|
| 707 | var->set_fromstring_fn = owl_variable_int_set_fromstring_default; |
---|
| 708 | var->get_fn = owl_variable_get_default; |
---|
| 709 | var->get_tostring_fn = owl_variable_int_get_tostring_default; |
---|
[bbd74a9] | 710 | var->delete_fn = owl_variable_delete_default; |
---|
[96828e4] | 711 | var->val = g_new(int, 1); |
---|
[d536e72] | 712 | var->set_fn(var, &initval); |
---|
| 713 | owl_variable_dict_add_variable(vd, var); |
---|
| 714 | } |
---|
[a695a68] | 715 | } |
---|
| 716 | |
---|
[6f7d4f6] | 717 | void owl_variable_dict_newvar_bool(owl_vardict *vd, const char *name, const char *summ, const char *desc, int initval) |
---|
[bc1d648] | 718 | { |
---|
| 719 | owl_variable *old = owl_variable_get_var(vd, name); |
---|
[ca54fd6] | 720 | if (old && owl_variable_get_type(old) == OWL_VARIABLE_BOOL) { |
---|
[d536e72] | 721 | owl_variable_update(old, summ, desc); |
---|
| 722 | old->ival_default = initval; |
---|
| 723 | } else { |
---|
| 724 | owl_variable * var = owl_variable_newvar(name, summ, desc); |
---|
| 725 | var->type = OWL_VARIABLE_BOOL; |
---|
[1dab38e] | 726 | var->validsettings = "on,off"; |
---|
[d536e72] | 727 | var->ival_default = initval; |
---|
| 728 | var->validate_fn = owl_variable_bool_validate_default; |
---|
| 729 | var->set_fn = owl_variable_bool_set_default; |
---|
| 730 | var->set_fromstring_fn = owl_variable_bool_set_fromstring_default; |
---|
| 731 | var->get_fn = owl_variable_get_default; |
---|
| 732 | var->get_tostring_fn = owl_variable_bool_get_tostring_default; |
---|
[bbd74a9] | 733 | var->delete_fn = owl_variable_delete_default; |
---|
[96828e4] | 734 | var->val = g_new(int, 1); |
---|
[d536e72] | 735 | var->set_fn(var, &initval); |
---|
| 736 | owl_variable_dict_add_variable(vd, var); |
---|
| 737 | } |
---|
[a695a68] | 738 | } |
---|
| 739 | |
---|
[0fef6eb] | 740 | void owl_variable_dict_cleanup(owl_vardict *d) |
---|
| 741 | { |
---|
[bf7aa1d] | 742 | owl_dict_cleanup(d, (void (*)(void *))owl_variable_delete); |
---|
[7d4fbcd] | 743 | } |
---|
| 744 | |
---|
[ce68f23] | 745 | CALLER_OWN GPtrArray *owl_variable_dict_get_names(const owl_vardict *d) { |
---|
| 746 | return owl_dict_get_keys(d); |
---|
[7d4fbcd] | 747 | } |
---|
| 748 | |
---|
[9efc154] | 749 | void owl_variable_cleanup(owl_variable *v) |
---|
[3b0edaa] | 750 | { |
---|
[bbd74a9] | 751 | if (v->delete_fn) v->delete_fn(v); |
---|
[ddbbcffa] | 752 | g_free(v->name); |
---|
| 753 | g_free(v->summary); |
---|
| 754 | g_free(v->description); |
---|
[ea68035] | 755 | if (v->type == OWL_VARIABLE_STRING) |
---|
| 756 | g_free(v->pval_default); |
---|
[9efc154] | 757 | } |
---|
| 758 | |
---|
| 759 | void owl_variable_delete(owl_variable *v) |
---|
| 760 | { |
---|
| 761 | owl_variable_cleanup(v); |
---|
[ddbbcffa] | 762 | g_free(v); |
---|
[7d4fbcd] | 763 | } |
---|
| 764 | |
---|
| 765 | |
---|
[ca54fd6] | 766 | const char *owl_variable_get_name(const owl_variable *v) |
---|
| 767 | { |
---|
| 768 | return v->name; |
---|
| 769 | } |
---|
| 770 | |
---|
[64735f0] | 771 | const char *owl_variable_get_description(const owl_variable *v) { |
---|
[aa2f33b3] | 772 | return v->description; |
---|
| 773 | } |
---|
| 774 | |
---|
[64735f0] | 775 | const char *owl_variable_get_summary(const owl_variable *v) { |
---|
[aa2f33b3] | 776 | return v->summary; |
---|
[7d4fbcd] | 777 | } |
---|
| 778 | |
---|
[64735f0] | 779 | const char *owl_variable_get_validsettings(const owl_variable *v) { |
---|
[fa981f3] | 780 | return v->validsettings; |
---|
[7d4fbcd] | 781 | } |
---|
| 782 | |
---|
[ca54fd6] | 783 | int owl_variable_get_type(const owl_variable *v) |
---|
| 784 | { |
---|
| 785 | return v->type; |
---|
| 786 | } |
---|
| 787 | |
---|
[7d4fbcd] | 788 | /* functions for getting and setting variable values */ |
---|
| 789 | |
---|
| 790 | /* returns 0 on success, prints a status msg if msg is true */ |
---|
[ca54fd6] | 791 | int owl_variable_set_fromstring(owl_variable *v, const char *value, int msg) { |
---|
[010a951] | 792 | char *tostring; |
---|
[7d4fbcd] | 793 | if (!v->set_fromstring_fn) { |
---|
[ca54fd6] | 794 | if (msg) owl_function_error("Variable %s is read-only", owl_variable_get_name(v)); |
---|
[486688f] | 795 | return -1; |
---|
[7d4fbcd] | 796 | } |
---|
| 797 | if (0 != v->set_fromstring_fn(v, value)) { |
---|
[ca54fd6] | 798 | if (msg) owl_function_error("Unable to set %s (must be %s)", owl_variable_get_name(v), |
---|
| 799 | owl_variable_get_validsettings(v)); |
---|
[7d4fbcd] | 800 | return -1; |
---|
| 801 | } |
---|
[fa981f3] | 802 | if (msg) { |
---|
[779bd3d] | 803 | tostring = v->get_tostring_fn(v, v->get_fn(v)); |
---|
[ca749a9] | 804 | if (tostring) |
---|
| 805 | owl_function_makemsg("%s = '%s'", owl_variable_get_name(v), tostring); |
---|
| 806 | else |
---|
| 807 | owl_function_makemsg("%s = <null>", owl_variable_get_name(v)); |
---|
[010a951] | 808 | g_free(tostring); |
---|
[7d4fbcd] | 809 | } |
---|
| 810 | return 0; |
---|
| 811 | } |
---|
| 812 | |
---|
[ca54fd6] | 813 | int owl_variable_set_string(owl_variable *v, const char *newval) |
---|
| 814 | { |
---|
| 815 | if (v->type != OWL_VARIABLE_STRING) return -1; |
---|
[ba6c8bd] | 816 | return v->set_fn(v, newval); |
---|
[7d4fbcd] | 817 | } |
---|
| 818 | |
---|
[ca54fd6] | 819 | int owl_variable_set_int(owl_variable *v, int newval) |
---|
| 820 | { |
---|
| 821 | if (v->type != OWL_VARIABLE_INT && v->type != OWL_VARIABLE_BOOL) return -1; |
---|
[7d4fbcd] | 822 | return v->set_fn(v, &newval); |
---|
| 823 | } |
---|
| 824 | |
---|
[ca54fd6] | 825 | int owl_variable_set_bool_on(owl_variable *v) |
---|
| 826 | { |
---|
| 827 | if (v->type != OWL_VARIABLE_BOOL) return -1; |
---|
| 828 | return owl_variable_set_int(v, true); |
---|
[7d4fbcd] | 829 | } |
---|
| 830 | |
---|
[ca54fd6] | 831 | int owl_variable_set_bool_off(owl_variable *v) |
---|
| 832 | { |
---|
| 833 | if (v->type != OWL_VARIABLE_BOOL) return -1; |
---|
| 834 | return owl_variable_set_int(v, false); |
---|
[7d4fbcd] | 835 | } |
---|
| 836 | |
---|
[ca54fd6] | 837 | CALLER_OWN char *owl_variable_get_tostring(const owl_variable *v) |
---|
[d427f08] | 838 | { |
---|
[779bd3d] | 839 | return v->get_tostring_fn(v, v->get_fn(v)); |
---|
[7d4fbcd] | 840 | } |
---|
| 841 | |
---|
[ca54fd6] | 842 | CALLER_OWN char *owl_variable_get_default_tostring(const owl_variable *v) |
---|
[d427f08] | 843 | { |
---|
[7d4fbcd] | 844 | if (v->type == OWL_VARIABLE_INT || v->type == OWL_VARIABLE_BOOL) { |
---|
[010a951] | 845 | return v->get_tostring_fn(v, &(v->ival_default)); |
---|
[7d4fbcd] | 846 | } else { |
---|
[010a951] | 847 | return v->get_tostring_fn(v, v->pval_default); |
---|
[7d4fbcd] | 848 | } |
---|
| 849 | } |
---|
| 850 | |
---|
[bc1d648] | 851 | owl_variable *owl_variable_get_var(const owl_vardict *d, const char *name) |
---|
| 852 | { |
---|
[fa981f3] | 853 | return owl_dict_find_element(d, name); |
---|
[d536e72] | 854 | } |
---|
| 855 | |
---|
| 856 | /* returns a reference */ |
---|
[ca54fd6] | 857 | const void *owl_variable_get(const owl_variable *v) |
---|
[bc1d648] | 858 | { |
---|
[7d4fbcd] | 859 | return v->get_fn(v); |
---|
| 860 | } |
---|
| 861 | |
---|
[ca54fd6] | 862 | const char *owl_variable_get_string(const owl_variable *v) |
---|
| 863 | { |
---|
| 864 | if (owl_variable_get_type(v) != OWL_VARIABLE_STRING) { |
---|
| 865 | owl_function_error("Variable '%s' is not a string.", owl_variable_get_name(v)); |
---|
| 866 | return NULL; |
---|
| 867 | } |
---|
| 868 | return owl_variable_get(v); |
---|
[7d4fbcd] | 869 | } |
---|
| 870 | |
---|
| 871 | /* returns a reference */ |
---|
[ca54fd6] | 872 | const void *owl_variable_get_other(const owl_variable *v) |
---|
| 873 | { |
---|
| 874 | if (owl_variable_get_type(v) != OWL_VARIABLE_OTHER) { |
---|
| 875 | owl_function_error("Variable '%s' is not type other.", owl_variable_get_name(v)); |
---|
| 876 | return NULL; |
---|
| 877 | } |
---|
| 878 | return owl_variable_get(v); |
---|
[7d4fbcd] | 879 | } |
---|
| 880 | |
---|
[ca54fd6] | 881 | int owl_variable_get_int(const owl_variable *v) |
---|
| 882 | { |
---|
| 883 | if (owl_variable_get_type(v) != OWL_VARIABLE_INT) { |
---|
| 884 | owl_function_error("Variable '%s' is an int.", owl_variable_get_name(v)); |
---|
| 885 | return -1; |
---|
| 886 | } |
---|
| 887 | const int *pi = owl_variable_get(v); |
---|
[bc1d648] | 888 | if (!pi) return -1; |
---|
| 889 | return *pi; |
---|
[7d4fbcd] | 890 | } |
---|
| 891 | |
---|
[ca54fd6] | 892 | int owl_variable_get_bool(const owl_variable *v) |
---|
| 893 | { |
---|
| 894 | if (owl_variable_get_type(v) != OWL_VARIABLE_BOOL) { |
---|
| 895 | owl_function_error("Variable '%s' is a boolean.", owl_variable_get_name(v)); |
---|
| 896 | return -1; |
---|
| 897 | } |
---|
| 898 | const int *pi = owl_variable_get(v); |
---|
[bc1d648] | 899 | if (!pi) return -1; |
---|
| 900 | return *pi; |
---|
[7d4fbcd] | 901 | } |
---|
| 902 | |
---|
[ca54fd6] | 903 | void owl_variable_describe(const owl_variable *v, owl_fmtext *fm) |
---|
| 904 | { |
---|
[ca749a9] | 905 | char *tostring = owl_variable_get_default_tostring(v); |
---|
| 906 | char *default_buf; |
---|
| 907 | |
---|
| 908 | if (tostring) |
---|
| 909 | default_buf = g_strdup_printf("'%s'", tostring); |
---|
| 910 | else |
---|
| 911 | default_buf = g_strdup("<null>"); |
---|
| 912 | owl_fmtext_appendf_normal(fm, OWL_TABSTR "%-20s - %s (default: %s)\n", |
---|
| 913 | owl_variable_get_name(v), |
---|
| 914 | owl_variable_get_summary(v), default_buf); |
---|
[010a951] | 915 | g_free(default_buf); |
---|
[ca749a9] | 916 | g_free(tostring); |
---|
[7d4fbcd] | 917 | } |
---|
| 918 | |
---|
[ca54fd6] | 919 | void owl_variable_get_help(const owl_variable *v, owl_fmtext *fm) { |
---|
[010a951] | 920 | char *tostring; |
---|
[7d4fbcd] | 921 | |
---|
| 922 | owl_fmtext_append_bold(fm, "OWL VARIABLE\n\n"); |
---|
| 923 | owl_fmtext_append_normal(fm, OWL_TABSTR); |
---|
[ca54fd6] | 924 | owl_fmtext_append_normal(fm, owl_variable_get_name(v)); |
---|
[7d4fbcd] | 925 | owl_fmtext_append_normal(fm, " - "); |
---|
[ca54fd6] | 926 | owl_fmtext_append_normal(fm, owl_variable_get_summary(v)); |
---|
[7d4fbcd] | 927 | owl_fmtext_append_normal(fm, "\n\n"); |
---|
| 928 | |
---|
| 929 | owl_fmtext_append_normal(fm, "Current: "); |
---|
[ca54fd6] | 930 | tostring = owl_variable_get_tostring(v); |
---|
[ca749a9] | 931 | owl_fmtext_append_normal(fm, (tostring ? tostring : "<null>")); |
---|
[010a951] | 932 | g_free(tostring); |
---|
[7d4fbcd] | 933 | owl_fmtext_append_normal(fm, "\n\n"); |
---|
| 934 | |
---|
| 935 | |
---|
[ca54fd6] | 936 | tostring = owl_variable_get_default_tostring(v); |
---|
[7d4fbcd] | 937 | owl_fmtext_append_normal(fm, "Default: "); |
---|
[ca749a9] | 938 | owl_fmtext_append_normal(fm, (tostring ? tostring : "<null>")); |
---|
[7d4fbcd] | 939 | owl_fmtext_append_normal(fm, "\n\n"); |
---|
| 940 | |
---|
| 941 | owl_fmtext_append_normal(fm, "Valid Settings: "); |
---|
| 942 | owl_fmtext_append_normal(fm, owl_variable_get_validsettings(v)); |
---|
| 943 | owl_fmtext_append_normal(fm, "\n\n"); |
---|
[aa2f33b3] | 944 | |
---|
| 945 | if (v->description && *v->description) { |
---|
| 946 | owl_fmtext_append_normal(fm, "Description:\n"); |
---|
| 947 | owl_fmtext_append_normal(fm, owl_variable_get_description(v)); |
---|
| 948 | owl_fmtext_append_normal(fm, "\n\n"); |
---|
| 949 | } |
---|
[010a951] | 950 | g_free(tostring); |
---|
[7d4fbcd] | 951 | } |
---|
| 952 | |
---|
| 953 | |
---|
| 954 | |
---|
| 955 | |
---|
| 956 | /**************************************************************************/ |
---|
| 957 | /*********************** GENERAL TYPE-SPECIFIC ****************************/ |
---|
| 958 | /**************************************************************************/ |
---|
| 959 | |
---|
| 960 | /* default common functions */ |
---|
| 961 | |
---|
[64735f0] | 962 | const void *owl_variable_get_default(const owl_variable *v) { |
---|
[7d4fbcd] | 963 | return v->val; |
---|
| 964 | } |
---|
| 965 | |
---|
[bbd74a9] | 966 | void owl_variable_delete_default(owl_variable *v) |
---|
| 967 | { |
---|
[3b8a563] | 968 | g_free(v->val); |
---|
[7d4fbcd] | 969 | } |
---|
| 970 | |
---|
| 971 | /* default functions for booleans */ |
---|
| 972 | |
---|
[64735f0] | 973 | int owl_variable_bool_validate_default(const owl_variable *v, const void *newval) { |
---|
[7d4fbcd] | 974 | if (newval == NULL) return(0); |
---|
[defe4a3] | 975 | else if (*(const int*)newval==1 || *(const int*)newval==0) return(1); |
---|
[7d4fbcd] | 976 | else return (0); |
---|
| 977 | } |
---|
| 978 | |
---|
[e19eb97] | 979 | int owl_variable_bool_set_default(owl_variable *v, const void *newval) { |
---|
[7d4fbcd] | 980 | if (v->validate_fn) { |
---|
| 981 | if (!v->validate_fn(v, newval)) return(-1); |
---|
| 982 | } |
---|
[defe4a3] | 983 | *(int*)v->val = *(const int*)newval; |
---|
[7d4fbcd] | 984 | return(0); |
---|
| 985 | } |
---|
| 986 | |
---|
[e19eb97] | 987 | int owl_variable_bool_set_fromstring_default(owl_variable *v, const char *newval) { |
---|
[7d4fbcd] | 988 | int i; |
---|
| 989 | if (!strcmp(newval, "on")) i=1; |
---|
| 990 | else if (!strcmp(newval, "off")) i=0; |
---|
| 991 | else return(-1); |
---|
| 992 | return (v->set_fn(v, &i)); |
---|
| 993 | } |
---|
| 994 | |
---|
[6829afc] | 995 | CALLER_OWN char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val) |
---|
[d427f08] | 996 | { |
---|
[7d4fbcd] | 997 | if (val == NULL) { |
---|
[ca749a9] | 998 | return NULL; |
---|
[defe4a3] | 999 | } else if (*(const int*)val == 0) { |
---|
[010a951] | 1000 | return g_strdup("off"); |
---|
[defe4a3] | 1001 | } else if (*(const int*)val == 1) { |
---|
[010a951] | 1002 | return g_strdup("on"); |
---|
[7d4fbcd] | 1003 | } else { |
---|
[010a951] | 1004 | return g_strdup("<invalid>"); |
---|
[7d4fbcd] | 1005 | } |
---|
| 1006 | } |
---|
| 1007 | |
---|
| 1008 | /* default functions for integers */ |
---|
| 1009 | |
---|
[64735f0] | 1010 | int owl_variable_int_validate_default(const owl_variable *v, const void *newval) { |
---|
[7d4fbcd] | 1011 | if (newval == NULL) return(0); |
---|
| 1012 | else return (1); |
---|
| 1013 | } |
---|
| 1014 | |
---|
[e19eb97] | 1015 | int owl_variable_int_set_default(owl_variable *v, const void *newval) { |
---|
[7d4fbcd] | 1016 | if (v->validate_fn) { |
---|
| 1017 | if (!v->validate_fn(v, newval)) return(-1); |
---|
| 1018 | } |
---|
[defe4a3] | 1019 | *(int*)v->val = *(const int*)newval; |
---|
[7d4fbcd] | 1020 | return(0); |
---|
| 1021 | } |
---|
| 1022 | |
---|
[e19eb97] | 1023 | int owl_variable_int_set_fromstring_default(owl_variable *v, const char *newval) { |
---|
[7d4fbcd] | 1024 | int i; |
---|
[99525be] | 1025 | char *ep; |
---|
| 1026 | i = strtol(newval, &ep, 10); |
---|
[7d4fbcd] | 1027 | if (*ep || ep==newval) return(-1); |
---|
| 1028 | return (v->set_fn(v, &i)); |
---|
| 1029 | } |
---|
| 1030 | |
---|
[6829afc] | 1031 | CALLER_OWN char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val) |
---|
[d427f08] | 1032 | { |
---|
[7d4fbcd] | 1033 | if (val == NULL) { |
---|
[ca749a9] | 1034 | return NULL; |
---|
[7d4fbcd] | 1035 | } else { |
---|
[010a951] | 1036 | return g_strdup_printf("%d", *(const int*)val); |
---|
[7d4fbcd] | 1037 | } |
---|
| 1038 | } |
---|
| 1039 | |
---|
| 1040 | /* default functions for enums (a variant of integers) */ |
---|
| 1041 | |
---|
[64735f0] | 1042 | int owl_variable_enum_validate(const owl_variable *v, const void *newval) { |
---|
[7d4fbcd] | 1043 | char **enums; |
---|
| 1044 | int nenums, val; |
---|
| 1045 | if (newval == NULL) return(0); |
---|
[d275eb2] | 1046 | enums = g_strsplit_set(v->validsettings, ",", 0); |
---|
| 1047 | nenums = g_strv_length(enums); |
---|
| 1048 | g_strfreev(enums); |
---|
[defe4a3] | 1049 | val = *(const int*)newval; |
---|
[7d4fbcd] | 1050 | if (val < 0 || val >= nenums) { |
---|
| 1051 | return(0); |
---|
| 1052 | } |
---|
| 1053 | return(1); |
---|
| 1054 | } |
---|
| 1055 | |
---|
[e19eb97] | 1056 | int owl_variable_enum_set_fromstring(owl_variable *v, const char *newval) { |
---|
[7d4fbcd] | 1057 | char **enums; |
---|
[d275eb2] | 1058 | int i, val=-1; |
---|
[7d4fbcd] | 1059 | if (newval == NULL) return(-1); |
---|
[d275eb2] | 1060 | enums = g_strsplit_set(v->validsettings, ",", 0); |
---|
| 1061 | for (i = 0; enums[i] != NULL; i++) { |
---|
[7d4fbcd] | 1062 | if (0==strcmp(newval, enums[i])) { |
---|
| 1063 | val = i; |
---|
| 1064 | } |
---|
| 1065 | } |
---|
[d275eb2] | 1066 | g_strfreev(enums); |
---|
[7d4fbcd] | 1067 | if (val == -1) return(-1); |
---|
| 1068 | return (v->set_fn(v, &val)); |
---|
| 1069 | } |
---|
| 1070 | |
---|
[6829afc] | 1071 | CALLER_OWN char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val) |
---|
[d427f08] | 1072 | { |
---|
[7d4fbcd] | 1073 | char **enums; |
---|
| 1074 | int nenums, i; |
---|
[010a951] | 1075 | char *tostring; |
---|
[7d4fbcd] | 1076 | |
---|
| 1077 | if (val == NULL) { |
---|
[ca749a9] | 1078 | return NULL; |
---|
[7d4fbcd] | 1079 | } |
---|
[d275eb2] | 1080 | enums = g_strsplit_set(v->validsettings, ",", 0); |
---|
| 1081 | nenums = g_strv_length(enums); |
---|
[defe4a3] | 1082 | i = *(const int*)val; |
---|
[7d4fbcd] | 1083 | if (i<0 || i>=nenums) { |
---|
[d275eb2] | 1084 | g_strfreev(enums); |
---|
[010a951] | 1085 | return g_strdup_printf("<invalid:%d>", i); |
---|
[7d4fbcd] | 1086 | } |
---|
[010a951] | 1087 | tostring = g_strdup(enums[i]); |
---|
[d275eb2] | 1088 | g_strfreev(enums); |
---|
[010a951] | 1089 | return tostring; |
---|
[7d4fbcd] | 1090 | } |
---|
| 1091 | |
---|
| 1092 | /* default functions for stringeans */ |
---|
| 1093 | |
---|
[64735f0] | 1094 | int owl_variable_string_validate_default(const struct _owl_variable *v, const void *newval) { |
---|
[7d4fbcd] | 1095 | if (newval == NULL) return(0); |
---|
| 1096 | else return (1); |
---|
| 1097 | } |
---|
| 1098 | |
---|
[e19eb97] | 1099 | int owl_variable_string_set_default(owl_variable *v, const void *newval) { |
---|
[7d4fbcd] | 1100 | if (v->validate_fn) { |
---|
| 1101 | if (!v->validate_fn(v, newval)) return(-1); |
---|
| 1102 | } |
---|
[3b8a563] | 1103 | g_free(v->val); |
---|
[d4927a7] | 1104 | v->val = g_strdup(newval); |
---|
[7d4fbcd] | 1105 | return(0); |
---|
| 1106 | } |
---|
| 1107 | |
---|
[e19eb97] | 1108 | int owl_variable_string_set_fromstring_default(owl_variable *v, const char *newval) { |
---|
[7d4fbcd] | 1109 | return (v->set_fn(v, newval)); |
---|
| 1110 | } |
---|
| 1111 | |
---|
[6829afc] | 1112 | CALLER_OWN char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val) |
---|
[d427f08] | 1113 | { |
---|
[ca749a9] | 1114 | return g_strdup((const char*)val); |
---|
[7d4fbcd] | 1115 | } |
---|
| 1116 | |
---|