Go to the source code of this file.
Functions | |
static int | tcl_getdesc (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_setdesc (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_getowner (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_setowner (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_getgots (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_setpwd (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_getpwd (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_getfiles (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_getdirs (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_hide (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_unhide (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_setflags (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_getflags (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_mkdir (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_rmdir (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_mv_cp (Tcl_Interp *irp, int argc, char **argv, int copy) |
static int | tcl_mv (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_cp (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_fileresend_send (ClientData cd, Tcl_Interp *irp, int argc, char *argv[], int resend) |
static int | tcl_fileresend (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
static int | tcl_filesend (ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) |
Variables | |
static tcl_cmds | mytcls [] |
static int tcl_cp | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 573 of file tclfiles.c.
References tcl_mv_cp().
00574 { 00575 return tcl_mv_cp(irp, argc, argv, 1); 00576 }
static int tcl_fileresend | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 599 of file tclfiles.c.
References tcl_fileresend_send().
00601 { 00602 return tcl_fileresend_send(cd, irp, argc, argv, 1); 00603 }
static int tcl_fileresend_send | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[], | |||
int | resend | |||
) | [static] |
Definition at line 578 of file tclfiles.c.
References DCC_FILES, files_reget(), and NULL.
Referenced by tcl_fileresend(), and tcl_filesend().
00580 { 00581 int i, idx; 00582 char s[21]; 00583 00584 BADARGS(3, 4, " idx filename ?nick?"); 00585 idx = atoi(argv[1]); 00586 if (idx < 0 || dcc[idx].type != &DCC_FILES) { 00587 Tcl_AppendResult(irp, "invalid idx", NULL); 00588 return TCL_ERROR; 00589 } 00590 if (argc == 4) 00591 i = files_reget(idx, argv[2], argv[3], resend); 00592 else 00593 i = files_reget(idx, argv[2], "", resend); 00594 sprintf(s, "%d", i); 00595 Tcl_AppendResult(irp, s, NULL); 00596 return TCL_OK; 00597 }
static int tcl_filesend | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 605 of file tclfiles.c.
References tcl_fileresend_send().
00606 { 00607 return tcl_fileresend_send(cd, irp, argc, argv, 0); 00608 }
static int tcl_getdesc | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 31 of file tclfiles.c.
References filedb_getdesc(), and NULL.
00032 { 00033 char *s = NULL; 00034 00035 BADARGS(3, 3, " dir file"); 00036 filedb_getdesc(argv[1], argv[2], &s); 00037 if (s) { 00038 Tcl_AppendResult(irp, s, NULL); 00039 free_null(s); 00040 return TCL_OK; 00041 } else { 00042 Tcl_AppendResult(irp, "filedb access failed", NULL); 00043 return TCL_ERROR; 00044 } 00045 }
static int tcl_getdirs | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 126 of file tclfiles.c.
References filedb_getdirs().
00127 { 00128 BADARGS(2, 2, " dir"); 00129 filedb_getdirs(irp, argv[1]); 00130 return TCL_OK; 00131 }
static int tcl_getfiles | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 119 of file tclfiles.c.
References filedb_getfiles().
00120 { 00121 BADARGS(2, 2, " dir"); 00122 filedb_getfiles(irp, argv[1]); 00123 return TCL_OK; 00124 }
static int tcl_getflags | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 205 of file tclfiles.c.
References filedb_entry::chan, FILE_DIR, filedb_getentry(), filedb_entry::flags_req, free_fdbe(), NULL, and filedb_entry::stat.
00206 { 00207 filedb_entry *fdbe; 00208 char *s = NULL, *p, *d; 00209 00210 BADARGS(2, 2, " dir"); 00211 realloc_strcpy(s, argv[1]); 00212 if (s[strlen(s) - 1] == '/') 00213 s[strlen(s) - 1] = 0; 00214 p = strrchr(s, '/'); 00215 if (p == NULL) { 00216 p = s; 00217 d = ""; 00218 } else { 00219 *p = 0; 00220 p++; 00221 d = s; 00222 } 00223 00224 fdbe = filedb_getentry(d, p); 00225 /* Directory doesn't exist? */ 00226 if (!fdbe || 00227 /* Not a directory? */ 00228 !(fdbe->stat & FILE_DIR)) { 00229 Tcl_AppendResult(irp, "", NULL); 00230 free_null(s); 00231 free_fdbe(&fdbe); 00232 return TCL_OK; 00233 } 00234 if (fdbe->flags_req) { 00235 realloc_strcpy(s, fdbe->flags_req); 00236 if (s[0] == '-') 00237 s[0] = 0; 00238 } else 00239 s[0] = 0; 00240 Tcl_AppendElement(irp, s); 00241 Tcl_AppendElement(irp, fdbe->chan); 00242 free_null(s); 00243 free_fdbe(&fdbe); 00244 return TCL_OK; 00245 }
static int tcl_getgots | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 77 of file tclfiles.c.
References filedb_getgots(), and NULL.
00078 { 00079 int i; 00080 char s[10]; 00081 00082 BADARGS(3, 3, " dir file"); 00083 i = filedb_getgots(argv[1], argv[2]); 00084 sprintf(s, "%d", i); 00085 Tcl_AppendResult(irp, s, NULL); 00086 return TCL_OK; 00087 }
static int tcl_getowner | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 54 of file tclfiles.c.
References filedb_getowner(), and NULL.
00055 { 00056 char *s = NULL; 00057 00058 BADARGS(3, 3, " dir file"); 00059 filedb_getowner(argv[1], argv[2], &s); 00060 if (s) { 00061 Tcl_AppendResult(irp, s, NULL); 00062 free_null(s); 00063 return TCL_OK; 00064 } else { 00065 Tcl_AppendResult(irp, "filedb access failed", NULL); 00066 return TCL_ERROR; 00067 } 00068 }
static int tcl_getpwd | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 104 of file tclfiles.c.
References DCC_FILES, and NULL.
00105 { 00106 int idx; 00107 00108 BADARGS(2, 2, " idx"); 00109 idx = atoi(argv[1]); 00110 if ((idx < 0) || (dcc[idx].type != &DCC_FILES)) { 00111 Tcl_AppendResult(irp, "invalid idx", NULL); 00112 return TCL_ERROR; 00113 } 00114 Tcl_AppendResult(irp, dcc[idx].u.file->dir, NULL); 00115 00116 return TCL_OK; 00117 }
static int tcl_hide | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 133 of file tclfiles.c.
References filedb_change().
00134 { 00135 BADARGS(3, 3, " dir file"); 00136 filedb_change(argv[1], argv[2]); 00137 return TCL_OK; 00138 }
static int tcl_mkdir | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 247 of file tclfiles.c.
References filedb_entry::chan, dccdir, FILE_DIR, filedb_addfile, filedb_close(), filedb_matchfile, filedb_open(), filedb_readtop(), filedb_updatefile, filedb_entry::filename, filedb_entry::flags_req, free_fdbe(), malloc_fdbe, now, NULL, filedb_entry::pos, filedb_entry::stat, UPDATE_ALL, and filedb_entry::uploaded.
00248 { 00249 FILE *fdb; 00250 filedb_entry *fdbe; 00251 char *s = NULL, *t, *d, *p; 00252 struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0}; 00253 00254 BADARGS(2, 4, " dir ?required-flags ?channel??"); 00255 realloc_strcpy(s, argv[1]); 00256 if (s[strlen(s) - 1] == '/') 00257 s[strlen(s) - 1] = 0; 00258 p = strrchr(s, '/'); 00259 if (p == NULL) { 00260 p = s; 00261 d = ""; 00262 } else { 00263 *p = 0; 00264 p++; 00265 d = s; 00266 } 00267 00268 fdb = filedb_open(d, 0); 00269 if (!fdb) { 00270 Tcl_AppendResult(irp, "-3", NULL); /* filedb access failed */ 00271 free_null(s); 00272 return TCL_OK; 00273 } 00274 filedb_readtop(fdb, NULL); 00275 fdbe = filedb_matchfile(fdb, ftell(fdb), p); 00276 00277 if (!fdbe) { 00278 t = malloc(strlen(dccdir) + strlen(d) + strlen(p) + 2); 00279 sprintf(t, "%s%s/%s", dccdir, d, p); 00280 if (mkdir(t, 0755) != 0) { 00281 Tcl_AppendResult(irp, "1", NULL); 00282 free_null(t); 00283 free_null(s); 00284 filedb_close(fdb); 00285 return TCL_OK; 00286 } 00287 fdbe = malloc_fdbe(); 00288 fdbe->stat = FILE_DIR; 00289 realloc_strcpy(fdbe->filename, argv[1]); 00290 fdbe->uploaded = now; 00291 } else if (!(fdbe->stat & FILE_DIR)) { 00292 Tcl_AppendResult(irp, "2", NULL); 00293 free_fdbe(&fdbe); 00294 free_null(s); 00295 filedb_close(fdb); 00296 return TCL_OK; 00297 } 00298 if (argc >= 3) { 00299 char f[100]; 00300 00301 break_down_flags(argv[2], &fr, NULL); 00302 build_flags(f, &fr, NULL); 00303 realloc_strcpy(fdbe->flags_req, f); 00304 } else if (fdbe->flags_req) { 00305 free_null(fdbe->flags_req); 00306 } 00307 if (argc == 4) { 00308 realloc_strcpy(fdbe->chan, argv[3]); 00309 } else 00310 if (fdbe->chan) 00311 free_null(fdbe->chan); 00312 00313 if (fdbe->pos) 00314 filedb_addfile(fdb, fdbe); 00315 else 00316 filedb_updatefile(fdb, fdbe->pos, fdbe, UPDATE_ALL); 00317 filedb_close(fdb); 00318 Tcl_AppendResult(irp, "0", NULL); 00319 return TCL_OK; 00320 }
static int tcl_mv | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 568 of file tclfiles.c.
References tcl_mv_cp().
00569 { 00570 return tcl_mv_cp(irp, argc, argv, 0); 00571 }
static int tcl_mv_cp | ( | Tcl_Interp * | irp, | |
int | argc, | |||
char ** | argv, | |||
int | copy | |||
) | [static] |
Definition at line 387 of file tclfiles.c.
References filedb_entry::chan, copyfile(), dccdir, filedb_entry::desc, FILE_DIR, FILE_HIDDEN, filedb_addfile, filedb_close(), filedb_delfile(), filedb_matchfile, filedb_open(), filedb_readtop(), filedb_entry::filename, filedb_entry::flags_req, free_fdbe(), filedb_entry::gots, malloc_fdbe, movefile(), NULL, filedb_entry::pos, resolve_dir(), filedb_entry::size, filedb_entry::stat, filedb_entry::uploaded, and filedb_entry::uploader.
Referenced by tcl_cp(), and tcl_mv().
00388 { 00389 char *p, *fn = NULL, *oldpath = NULL, *s = NULL, *s1 = NULL; 00390 char *newfn = NULL, *newpath = NULL; 00391 int ok = 0, only_first, skip_this; 00392 FILE *fdb_old, *fdb_new; 00393 filedb_entry *fdbe_old, *fdbe_new; 00394 long where; 00395 00396 BADARGS(3, 3, " oldfilepath newfilepath"); 00397 realloc_strcpy(fn, argv[1]); 00398 p = strrchr(fn, '/'); 00399 if (p != NULL) { 00400 *p = 0; 00401 realloc_strcpy(s, fn); 00402 strcpy(fn, p + 1); 00403 if (!resolve_dir("/", s, &oldpath, -1)) { 00404 /* Tcl can do * anything */ 00405 Tcl_AppendResult(irp, "-1", NULL); /* Invalid source */ 00406 free_null(fn); 00407 free_null(oldpath); 00408 return TCL_OK; 00409 } 00410 free_null(s); 00411 } else 00412 realloc_strcpy(oldpath, "/"); 00413 realloc_strcpy(s, argv[2]); 00414 if (!resolve_dir("/", s, &newpath, -1)) { 00415 /* Destination is not just a directory */ 00416 p = strrchr(s, '/'); 00417 if (!p) { 00418 realloc_strcpy(newfn, s); 00419 s[0] = 0; 00420 } else { 00421 *p = 0; 00422 realloc_strcpy(newfn, p + 1); 00423 } 00424 free_null(newpath); 00425 if (!resolve_dir("/", s, &newpath, -1)) { 00426 Tcl_AppendResult(irp, "-2", NULL); /* Invalid desto */ 00427 free_null(newpath); 00428 free_null(s); 00429 free_null(newfn); 00430 return TCL_OK; 00431 } 00432 } else 00433 realloc_strcpy(newfn, ""); 00434 free_null(s); 00435 00436 /* Stupidness checks */ 00437 if ((!strcmp(oldpath, newpath)) && 00438 (!newfn[0] || !strcmp(newfn, fn))) { 00439 free_null(newfn); 00440 free_null(fn); 00441 free_null(oldpath); 00442 free_null(newpath); 00443 Tcl_AppendResult(irp, "-3", NULL); /* Stupid copy to self */ 00444 return TCL_OK; 00445 } 00446 /* Be aware of 'cp * this.file' possibility: ONLY COPY FIRST ONE */ 00447 if ((strchr(fn, '?') || strchr(fn, '*')) && newfn[0]) 00448 only_first = 1; 00449 else 00450 only_first = 0; 00451 00452 fdb_old = filedb_open(oldpath, 0); 00453 if (!strcmp(oldpath, newpath)) 00454 fdb_new = fdb_old; 00455 else 00456 fdb_new = filedb_open(newpath, 0); 00457 if (!fdb_old || !fdb_new) { 00458 free_null(newfn); 00459 free_null(fn); 00460 free_null(oldpath); 00461 free_null(newpath); 00462 if (fdb_old) 00463 filedb_close(fdb_old); 00464 else if (fdb_new) 00465 filedb_close(fdb_new); 00466 Tcl_AppendResult(irp, "-5", NULL); /* DB access failed */ 00467 return -1; 00468 } 00469 00470 filedb_readtop(fdb_old, NULL); 00471 fdbe_old = filedb_matchfile(fdb_old, ftell(fdb_old), fn); 00472 if (!fdbe_old) { 00473 free_null(newfn); 00474 free_null(fn); 00475 free_null(oldpath); 00476 free_null(newpath); 00477 if (fdb_new != fdb_old) 00478 filedb_close(fdb_new); 00479 filedb_close(fdb_old); 00480 Tcl_AppendResult(irp, "-4", NULL); /* No match */ 00481 return -2; 00482 } 00483 while (fdbe_old) { 00484 where = ftell(fdb_old); 00485 skip_this = 0; 00486 if (!(fdbe_old->stat & (FILE_HIDDEN | FILE_DIR))) { 00487 s = malloc(strlen(dccdir) + strlen(oldpath) 00488 + strlen(fdbe_old->filename) + 2); 00489 s1 = malloc(strlen(dccdir) + strlen(newpath) 00490 + strlen(newfn[0] ? newfn : fdbe_old->filename) + 2); 00491 sprintf(s, "%s%s%s%s", dccdir, oldpath, 00492 oldpath[0] ? "/" : "", fdbe_old->filename); 00493 sprintf(s1, "%s%s%s%s", dccdir, newpath, 00494 newpath[0] ? "/" : "", newfn[0] ? newfn : fdbe_old->filename); 00495 if (!strcmp(s, s1)) { 00496 Tcl_AppendResult(irp, "-3", NULL); /* Stupid copy to self */ 00497 skip_this = 1; 00498 } 00499 /* Check for existence of file with same name in new dir */ 00500 filedb_readtop(fdb_new, NULL); 00501 fdbe_new = filedb_matchfile(fdb_new, ftell(fdb_new), 00502 newfn[0] ? newfn : fdbe_old->filename); 00503 if (fdbe_new) { 00504 /* It's ok if the entry in the new dir is a normal file (we'll 00505 * just scrap the old entry and overwrite the file) -- but if 00506 * it's a directory, this file has to be skipped. 00507 */ 00508 if (fdbe_new->stat & FILE_DIR) { 00509 /* Skip */ 00510 skip_this = 1; 00511 } else { 00512 filedb_delfile(fdb_new, fdbe_new->pos); 00513 } 00514 free_fdbe(&fdbe_new); 00515 } 00516 if (!skip_this) { 00517 if ((copy ? copyfile(s, s1) : movefile(s, s1)) == 0) { 00518 /* Raw file moved okay: create new entry for it */ 00519 ok++; 00520 fdbe_new = malloc_fdbe(); 00521 fdbe_new->stat = fdbe_old->stat; 00522 /* We don't have to worry about any entries to be 00523 * NULL, because realloc_strcpy takes care of that. 00524 */ 00525 realloc_strcpy(fdbe_new->flags_req, fdbe_old->flags_req); 00526 realloc_strcpy(fdbe_new->chan, fdbe_old->chan); 00527 realloc_strcpy(fdbe_new->filename, fdbe_old->filename); 00528 realloc_strcpy(fdbe_new->desc, fdbe_old->desc); 00529 if (newfn[0]) 00530 realloc_strcpy(fdbe_new->filename, newfn); 00531 realloc_strcpy(fdbe_new->uploader, fdbe_old->uploader); 00532 fdbe_new->uploaded = fdbe_old->uploaded; 00533 fdbe_new->size = fdbe_old->size; 00534 fdbe_new->gots = fdbe_old->gots; 00535 filedb_addfile(fdb_new, fdbe_new); 00536 if (!copy) 00537 filedb_delfile(fdb_old, fdbe_old->pos); 00538 free_fdbe(&fdbe_new); 00539 } 00540 } 00541 free_null(s); 00542 free_null(s1); 00543 } 00544 free_fdbe(&fdbe_old); 00545 fdbe_old = filedb_matchfile(fdb_old, where, fn); 00546 if (ok && only_first) { 00547 free_fdbe(&fdbe_old); 00548 } 00549 } 00550 if (fdb_old != fdb_new) 00551 filedb_close(fdb_new); 00552 filedb_close(fdb_old); 00553 if (!ok) 00554 Tcl_AppendResult(irp, "-4", NULL); /* No match */ 00555 else { 00556 char x[30]; 00557 00558 sprintf(x, "%d", ok); 00559 Tcl_AppendResult(irp, x, NULL); 00560 } 00561 free_null(newfn); 00562 free_null(fn); 00563 free_null(oldpath); 00564 free_null(newpath); 00565 return TCL_OK; 00566 }
static int tcl_rmdir | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 322 of file tclfiles.c.
References dccdir, FILE_DIR, filedb_close(), filedb_delfile(), filedb_matchfile, filedb_open(), filedb_readtop(), free_fdbe(), NULL, filedb_entry::pos, and filedb_entry::stat.
00323 { 00324 FILE *fdb; 00325 filedb_entry *fdbe; 00326 char *s = NULL, *t, *d, *p; 00327 00328 BADARGS(2, 2, " dir"); 00329 realloc_strcpy(s, argv[1]); 00330 if (s[strlen(s) - 1] == '/') 00331 s[strlen(s) - 1] = 0; 00332 p = strrchr(s, '/'); 00333 if (p == NULL) { 00334 p = s; 00335 d = ""; 00336 } else { 00337 *p = 0; 00338 p++; 00339 d = s; 00340 } 00341 00342 fdb = filedb_open(d, 0); 00343 if (!fdb) { 00344 Tcl_AppendResult(irp, "1", NULL); 00345 free_null(s); 00346 return TCL_OK; 00347 } 00348 filedb_readtop(fdb, NULL); 00349 fdbe = filedb_matchfile(fdb, ftell(fdb), p); 00350 00351 if (!fdbe) { 00352 Tcl_AppendResult(irp, "1", NULL); 00353 filedb_close(fdb); 00354 free_null(s); 00355 return TCL_OK; 00356 } 00357 if (!(fdbe->stat & FILE_DIR)) { 00358 Tcl_AppendResult(irp, "1", NULL); 00359 filedb_close(fdb); 00360 free_fdbe(&fdbe); 00361 free_null(s); 00362 return TCL_OK; 00363 } 00364 /* Erase '.filedb' and '.files' if they exist */ 00365 t = malloc(strlen(dccdir) + strlen(d) + strlen(p) + 11); 00366 sprintf(t, "%s%s/%s/.filedb", dccdir, d, p); 00367 unlink(t); 00368 sprintf(t, "%s%s/%s/.files", dccdir, d, p); 00369 unlink(t); 00370 sprintf(t, "%s%s/%s", dccdir, d, p); 00371 free_null(s); 00372 if (rmdir(t) == 0) { 00373 filedb_delfile(fdb, fdbe->pos); 00374 filedb_close(fdb); 00375 free_fdbe(&fdbe); 00376 free_null(t); 00377 Tcl_AppendResult(irp, "0", NULL); 00378 return TCL_OK; 00379 } 00380 free_null(t); 00381 free_fdbe(&fdbe); 00382 filedb_close(fdb); 00383 Tcl_AppendResult(irp, "1", NULL); 00384 return TCL_OK; 00385 }
static int tcl_setdesc | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 47 of file tclfiles.c.
References filedb_setdesc().
00048 { 00049 BADARGS(4, 4, " dir file desc"); 00050 filedb_setdesc(argv[1], argv[2], argv[3]); 00051 return TCL_OK; 00052 }
static int tcl_setflags | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 147 of file tclfiles.c.
References filedb_entry::chan, FILE_DIR, filedb_close(), filedb_matchfile, filedb_open(), filedb_readtop(), filedb_updatefile, filedb_entry::flags_req, free_fdbe(), NULL, filedb_entry::pos, filedb_entry::stat, and UPDATE_ALL.
00148 { 00149 FILE *fdb; 00150 filedb_entry *fdbe; 00151 char *s = NULL, *p, *d; 00152 00153 BADARGS(3, 4, " dir ?flags ?channel??"); 00154 realloc_strcpy(s, argv[1]); 00155 if (s[strlen(s) - 1] == '/') 00156 s[strlen(s) - 1] = 0; 00157 p = strrchr(s, '/'); 00158 if (p == NULL) { 00159 p = s; 00160 d = ""; 00161 } else { 00162 *p = 0; 00163 p++; 00164 d = s; 00165 } 00166 00167 fdb = filedb_open(d, 0); 00168 if (!fdb) { 00169 Tcl_AppendResult(irp, "-3", NULL); /* filedb access failed */ 00170 free_null(s); 00171 return TCL_OK; 00172 } 00173 filedb_readtop(fdb, NULL); 00174 fdbe = filedb_matchfile(fdb, ftell(fdb), p); 00175 free_null(s); 00176 00177 if (!fdbe) { 00178 Tcl_AppendResult(irp, "-1", NULL); /* No such dir */ 00179 return TCL_OK; 00180 } 00181 if (!(fdbe->stat & FILE_DIR)) { 00182 Tcl_AppendResult(irp, "-2", NULL); /* Not a dir */ 00183 return TCL_OK; 00184 } 00185 if (argc >= 3) { 00186 struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0}; 00187 char f[100]; 00188 00189 break_down_flags(argv[2], &fr, NULL); 00190 build_flags(f, &fr, NULL); 00191 realloc_strcpy(fdbe->flags_req, f); 00192 } else { 00193 free_null(fdbe->flags_req); 00194 } 00195 if (argc == 4) 00196 realloc_strcpy(fdbe->chan, argv[3]); 00197 00198 filedb_updatefile(fdb, fdbe->pos, fdbe, UPDATE_ALL); 00199 free_fdbe(&fdbe); 00200 filedb_close(fdb); 00201 Tcl_AppendResult(irp, "0", NULL); 00202 return TCL_OK; 00203 }
static int tcl_setowner | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 70 of file tclfiles.c.
References filedb_setowner().
00071 { 00072 BADARGS(4, 4, " dir file owner"); 00073 filedb_setowner(argv[1], argv[2], argv[3]); 00074 return TCL_OK; 00075 }
static int tcl_setpwd | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 89 of file tclfiles.c.
References DCC_FILES, files_setpwd(), and NULL.
00090 { 00091 int idx; 00092 00093 BADARGS(3, 3, " idx dir"); 00094 idx = atoi(argv[1]); 00095 if ((idx < 0) || (dcc[idx].type != &DCC_FILES)) { 00096 Tcl_AppendResult(irp, "invalid idx", NULL); 00097 return TCL_ERROR; 00098 } 00099 files_setpwd(idx, argv[2]); 00100 00101 return TCL_OK; 00102 }
static int tcl_unhide | ( | ClientData | cd, | |
Tcl_Interp * | irp, | |||
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 140 of file tclfiles.c.
References filedb_change().
00141 { 00142 BADARGS(3, 3, " dir file"); 00143 filedb_change(argv[1], argv[2]); 00144 return TCL_OK; 00145 }
tcl_cmds mytcls[] [static] |
Initial value:
{ {"getdesc", tcl_getdesc}, {"getowner", tcl_getowner}, {"setdesc", tcl_setdesc}, {"setowner", tcl_setowner}, {"getgots", tcl_getgots}, {"getpwd", tcl_getpwd}, {"setpwd", tcl_setpwd}, {"getfiles", tcl_getfiles}, {"getdirs", tcl_getdirs}, {"hide", tcl_hide}, {"unhide", tcl_unhide}, {"filesend", tcl_filesend}, {"fileresend", tcl_fileresend}, {"mkdir", tcl_mkdir}, {"rmdir", tcl_rmdir}, {"cp", tcl_cp}, {"mv", tcl_mv}, {"getflags", tcl_getflags}, {"setflags", tcl_setflags}, {NULL, NULL} }
Definition at line 610 of file tclfiles.c.
Referenced by filesys_close(), and start().