#include <eggdrop/eggdrop.h>
#include "egg_script_internal.h"
Go to the source code of this file.
Functions | |
static void * | resolve_path (void *root, char *path) |
static char * | script_config_get (char *handle, char *path) |
static int | script_config_set (char *handle, char *path, char *val) |
static int | script_config_exists (char *handle, char *path) |
static int | script_config_load (char *handle, char *fname) |
Variables | |
static const char | rcsid [] = "$Id: scriptconfig.c,v 1.11 2008-10-17 15:57:43 sven Exp $" |
script_command_t | script_config_cmds [] |
static void* resolve_path | ( | void * | root, | |
char * | path | |||
) | [static] |
Definition at line 27 of file scriptconfig.c.
References config_lookup_section(), and NULL.
Referenced by script_config_get(), and script_config_set().
00028 { 00029 char *save, *work, *period; 00030 00031 if (!root) return(NULL); 00032 00033 work = strdup(path); 00034 save = work; 00035 while ((period = strchr(work, '.'))) { 00036 *period = 0; 00037 root = config_lookup_section(root, work, 0, NULL); 00038 if (!root) goto done; 00039 work = period+1; 00040 } 00041 root = config_lookup_section(root, work, 0, NULL); 00042 done: 00043 free(save); 00044 return(root); 00045 }
static int script_config_exists | ( | char * | handle, | |
char * | path | |||
) | [static] |
Definition at line 76 of file scriptconfig.c.
References config_exists(), config_get_root(), config_lookup_section(), and NULL.
00077 { 00078 void *root; 00079 char *save, *work, *period; 00080 int r = 0; 00081 00082 if (!handle) handle = "eggdrop"; 00083 00084 root = config_get_root(handle); 00085 if (!root) return(0); 00086 00087 work = strdup(path); 00088 save = work; 00089 while ((period = strchr(work, '.'))) { 00090 *period = 0; 00091 if (!config_exists(root, work, 0, NULL)) goto notfound; 00092 root = config_lookup_section(root, work, 0, NULL); 00093 if (!root) goto notfound; 00094 work = period+1; 00095 } 00096 r = (config_exists(root, work, 0, NULL) == NULL) ? 0 : 1; 00097 00098 notfound: 00099 free(save); 00100 return(r); 00101 }
static char* script_config_get | ( | char * | handle, | |
char * | path | |||
) | [static] |
Definition at line 47 of file scriptconfig.c.
References config_get_root(), config_get_str(), NULL, and resolve_path().
00048 { 00049 void *root; 00050 char *str = NULL; 00051 00052 if (!handle) handle = "eggdrop"; 00053 00054 root = config_get_root(handle); 00055 root = resolve_path(root, path); 00056 if (!root) return(NULL); 00057 00058 config_get_str(&str, root, NULL); 00059 return(str); 00060 }
static int script_config_load | ( | char * | handle, | |
char * | fname | |||
) | [static] |
Definition at line 103 of file scriptconfig.c.
References config_load(), and config_set_root().
00104 { 00105 void *root; 00106 00107 root = config_load(fname); 00108 if (!root) return(-1); 00109 config_set_root(handle, root); 00110 return(0); 00111 }
static int script_config_set | ( | char * | handle, | |
char * | path, | |||
char * | val | |||
) | [static] |
Definition at line 62 of file scriptconfig.c.
References config_get_root(), config_set_str(), NULL, and resolve_path().
00063 { 00064 void *root; 00065 00066 if (!handle) handle = "eggdrop"; 00067 00068 root = config_get_root(handle); 00069 root = resolve_path(root, path); 00070 if (!root) return(-1); 00071 00072 config_set_str(val, root, NULL); 00073 return(0); 00074 }
const char rcsid[] = "$Id: scriptconfig.c,v 1.11 2008-10-17 15:57:43 sven Exp $" [static] |
Definition at line 21 of file scriptconfig.c.
Initial value:
{ {"config", "exists", script_config_exists, NULL, 1, "ss", "?handle? path", SCRIPT_INTEGER, SCRIPT_VAR_ARGS|SCRIPT_VAR_FRONT}, {"config", "get", script_config_get, NULL, 1, "ss", "?handle? path", SCRIPT_STRING, SCRIPT_VAR_ARGS|SCRIPT_VAR_FRONT}, {"config", "set", script_config_set, NULL, 2, "sss", "?handle? path value", SCRIPT_INTEGER, SCRIPT_VAR_ARGS|SCRIPT_VAR_FRONT}, {"config", "load", script_config_load, NULL, 2, "ss", "handle filename", SCRIPT_INTEGER, 0}, {"config", "save", config_save, NULL, 2, "ss", "handle filename", SCRIPT_INTEGER, 0}, {0} }
Definition at line 113 of file scriptconfig.c.