diff options
Diffstat (limited to 'proc/vos_set.c')
| -rw-r--r-- | proc/vos_set.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/proc/vos_set.c b/proc/vos_set.c index 7fc3899..ec00f4d 100644 --- a/proc/vos_set.c +++ b/proc/vos_set.c @@ -1,5 +1,60 @@ #include "proc/vos_set.h" +static int set_proc_tmp_dir_value(char *tmp) +{ + int idx = 0; + int s = 0; + struct String *path = 0; + + s = str_create(&path); + if (s) + return s; + + if (*tmp == ':') { + tmp++; + idx = _vos.proc_tmp_dir->last->num; + } else + ll_destroy(&_vos.proc_tmp_dir); + + while (*tmp) { + /* skip '"' */ + tmp++; + + while(*tmp && *tmp != '"') { + s = str_append_c(path, *tmp); + if (s) + return s; + tmp++; + } + + /* does user have write access ? */ + s = access(path->buf, W_OK); + if (s == 0) { + idx++; + s = ll_add(&_vos.proc_tmp_dir, idx, path->buf); + if (s) + return s; + } + + /* skip '"' */ + tmp++; + + /* skip ':' */ + if (*tmp && *tmp == ':') + tmp++; + else + break; + + str_prune(path); + } + + _vos.p_proc_tmp_dir = _vos.proc_tmp_dir; + + str_destroy(&path); + + return 0; +} + int vos_process_set(struct StmtSet *set) { switch (set->var_idx) { @@ -28,6 +83,11 @@ int vos_process_set(struct StmtSet *set) if (! _vos.proc_max_row) _vos.proc_max_row = VOS_DEF_PROC_MAX_ROW; break; + + case SET_PROC_TMP_DIR: + set_proc_tmp_dir_value(set->value); + break; } + return 0; } |
