static void filedb_getowner(char *dir, char *fn, char **owner) { filedb_entry *fdbe = NULL; fdbe = filedb_getentry(dir, fn); if (fdbe) { *owner = strdup(fdbe->uploader); free_fdbe(&fdbe); } else *owner = NULL; }
static void filedb_getdesc(char *dir, char *fn, char **desc) { filedb_entry *fdbe = NULL; fdbe = filedb_getentry(dir, fn); if (fdbe) { *desc = strdup(fdbe->desc); free_fdbe(&fdbe); } else *desc = NULL; }
static int filedb_getgots(char *dir, char *fn) { filedb_entry *fdbe = NULL; int gots = 0; fdbe = filedb_getentry(dir, fn); if (fdbe) { gots = fdbe->gots; free_fdbe(&fdbe); } return gots; }
static void filedb_getowner(char *dir, char *fn, char **owner) { filedb_entry *fdbe = NULL; fdbe = filedb_getentry(dir, fn); if (fdbe) { *owner = nmalloc(strlen(fdbe->uploader) + 1); strcpy(*owner, fdbe->uploader); free_fdbe(&fdbe); } else *owner = NULL; }
static void filedb_getlink(char *dir, char *fn, char **link) { filedb_entry *fdbe = NULL; fdbe = filedb_getentry(dir, fn); if (fdbe && (!(fdbe->stat & FILE_DIR))) { malloc_strcpy(*link, fdbe->sharelink); } else *link = NULL; if (fdbe) free_fdbe(&fdbe); return; }
static void filedb_getdesc(char *dir, char *fn, char **desc) { filedb_entry *fdbe = NULL; fdbe = filedb_getentry(dir, fn); if (fdbe) { if (fdbe->desc) { *desc = nmalloc(strlen(fdbe->desc) + 1); strcpy(*desc, fdbe->desc); } free_fdbe(&fdbe); } else *desc = NULL; }
static int tcl_getflags(ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) { filedb_entry *fdbe; char *s = NULL, *p, *d; BADARGS(2, 2, " dir"); malloc_strcpy(s, argv[1]); if (s[strlen(s) - 1] == '/') s[strlen(s) - 1] = 0; p = strrchr(s, '/'); if (p == NULL) { p = s; d = ""; } else { *p = 0; p++; d = s; } fdbe = filedb_getentry(d, p); /* Directory doesn't exist? */ if (!fdbe || !(fdbe->stat & FILE_DIR)) { Tcl_AppendResult(irp, "", NULL); my_free(s); free_fdbe(&fdbe); return TCL_OK; } if (fdbe->flags_req) { malloc_strcpy(s, fdbe->flags_req); if (s[0] == '-') s[0] = 0; } else s[0] = 0; Tcl_AppendElement(irp, s); Tcl_AppendElement(irp, fdbe->chan); my_free(s); free_fdbe(&fdbe); return TCL_OK; }