25 #include <sys/types.h>
28 #define S_ISREG(x) (x & _S_IFREG)
29 #define S_ISDIR(x) (x & _S_IFDIR)
37 #include <yaz/snprintf.h>
41 static int repComp(
const char *a,
const char *b,
size_t len)
45 return memcmp(a, b, len);
50 const char *base,
char *src)
53 size_t src_len = strlen(src);
60 yaz_snprintf(tmppath,
sizeof(tmppath),
"%s%s", base, dst->
path);
62 strcpy(tmppath, dst->
path);
67 strcpy(tmppath, dst->
path);
79 const char *base,
char *src,
84 static char tmppath[1024];
85 size_t src_len = strlen(src);
87 yaz_snprintf(tmppath,
sizeof(tmppath),
"%s%s", base, src);
89 yaz_log(YLOG_LOG,
"dir %s", tmppath);
91 if (!dst || strcmp(dst->
path, src))
96 if (src_len && src[src_len-1] !=
'/')
99 src[++src_len] =
'\0';
107 strcpy(src, dst->
path);
113 if (src_len && src[src_len-1] !=
'/')
116 src[++src_len] =
'\0';
128 if (e_src[i_src].
name)
130 yaz_log(YLOG_DEBUG,
"dst=%s src=%s", dst->
path + src_len,
132 sd = strcmp(dst->
path + src_len, e_src[i_src].
name);
137 else if (e_src[i_src].
name)
141 yaz_log(YLOG_DEBUG,
"trav sd=%d", sd);
145 strcpy(src + src_len, e_src[i_src].
name);
146 yaz_snprintf(tmppath,
sizeof(tmppath),
"%s%s", base, src);
148 switch(e_src[i_src].
kind)
157 yaz_log(YLOG_DEBUG,
"old: %s", ctime(&dst->
mtime));
158 yaz_log(YLOG_DEBUG,
"new: %s", ctime(&e_src[i_src].
mtime));
165 yaz_log(YLOG_DEBUG,
"last is %s", dst ? dst->
path :
"null");
175 strcpy(src + src_len, e_src[i_src].
name);
176 yaz_snprintf(tmppath,
sizeof(tmppath),
"%s%s", base, src);
178 switch (e_src[i_src].
kind)
194 strcpy(src, dst->
path);
195 yaz_snprintf(tmppath,
sizeof(tmppath),
"%s%s", base, dst->
path);
223 if (zh->
path_reg && !yaz_is_abspath(path))
234 src_len = strlen(src);
238 yaz_log(YLOG_WARN|YLOG_ERRNO,
"Cannot access path %s", src);
240 else if (S_ISREG(sbuf.st_mode))
248 if (sbuf.st_mtime > e_dst->
mtime)
260 else if (S_ISDIR(sbuf.st_mode))
262 if (src_len && src[src_len-1] !=
'/')
265 src[++src_len] =
'\0';
274 yaz_log(YLOG_WARN,
"Skipping path %s", src);
280 char fmatch_fname[1024];
284 yaz_snprintf(fmatch_fname,
sizeof(fmatch_fname),
FMATCH_DICT, ord);
288 yaz_log(YLOG_FATAL,
"dict_open fail of %s", fmatch_fname);
319 if (!strcmp(
path,
"") || !strcmp(
path,
"-"))
322 while (scanf(
"%s", src) == 1)
328 dump_file_dict(
dict);
void dict_clean(Dict dict)
reset Dictionary (makes it empty)
int dict_close(Dict dict)
closes dictionary
struct dir_entry * dir_open(const char *rep, const char *base, int follow_links)
void dir_sort(struct dir_entry *e)
int zebra_file_stat(const char *file_name, struct stat *buf, int follow_links)
void dir_free(struct dir_entry **e_p)
struct dirs_info * dirs_fopen(Dict dict, const char *path, int rw)
void dirs_mkdir(struct dirs_info *p, const char *src, time_t mtime)
void dirs_rmdir(struct dirs_info *p, const char *src)
struct dirs_entry * dirs_last(struct dirs_info *p)
void dirs_add(struct dirs_info *p, const char *src, zint sysno, time_t mtime)
void dirs_free(struct dirs_info **pp)
struct dirs_entry * dirs_read(struct dirs_info *p)
struct dirs_info * dirs_open(Dict dict, const char *rep, int rw)
void dirs_del(struct dirs_info *p, const char *src)
Dict dict_open_res(BFiles bfs, const char *name, int cache, int rw, int compact_flag, Res res)
struct zebra_register * reg
static ZEBRA_RES zebra_open_fmatch(ZebraHandle zh, Dict *dictp)
static void fileDelete_r(ZebraHandle zh, struct dirs_info *di, struct dirs_entry *dst, const char *base, char *src)
ZEBRA_RES zebra_remove_file_match(ZebraHandle zh)
ZEBRA_RES zebra_update_file_match(ZebraHandle zh, const char *path)
static void file_update_top(ZebraHandle zh, Dict dict, const char *path)
static void file_update_r(ZebraHandle zh, struct dirs_info *di, struct dirs_entry *dst, const char *base, char *src, int level)
static int repComp(const char *a, const char *b, size_t len)
short ZEBRA_RES
Common return type for Zebra API.
int zebraExplain_curDatabase(ZebraExplainInfo zei, const char *database)
int zebraExplain_get_database_ord(ZebraExplainInfo zei)
int zebraExplain_newDatabase(ZebraExplainInfo zei, const char *database, int explain_database)