static void testpair(struct cli_state *cli1, struct cli_state *cli2, char *mask, char *file) { int fnum; fstring res1, res2; char *res3; static int count; count++; fstrcpy(res1, "---"); fstrcpy(res2, "---"); fnum = cli_open(cli1, file, O_CREAT|O_TRUNC|O_RDWR, 0); if (fnum == -1) { DEBUG(0,("Can't create %s on cli1\n", file)); return; } cli_close(cli1, fnum); fnum = cli_open(cli2, file, O_CREAT|O_TRUNC|O_RDWR, 0); if (fnum == -1) { DEBUG(0,("Can't create %s on cli2\n", file)); return; } cli_close(cli2, fnum); resultp = res1; cli_list(cli1, mask, aHIDDEN | aDIR, listfn); res3 = reg_test(mask, file); resultp = res2; cli_list(cli2, mask, aHIDDEN | aDIR, listfn); if (showall || strcmp(res1, res2)) { DEBUG(0,("%s %s %s %d mask=[%s] file=[%s]\n", res1, res2, res3, count, mask, file)); } cli_unlink(cli1, file); cli_unlink(cli2, file); }
static BOOL gpo_sync_files(struct sync_context *ctx) { DEBUG(3,("calling cli_list with mask: %s\n", ctx->mask)); if (cli_list(ctx->cli, ctx->mask, ctx->attribute, gpo_sync_func, ctx) == -1) { DEBUG(1,("listing [%s] failed with error: %s\n", ctx->mask, cli_errstr(ctx->cli))); return False; } return True; }
void nb_deltree(const char *dname) { char *mask; if (asprintf(&mask, "%s\\*", dname) == -1) { printf("asprintf failed\n"); return; } total_deleted = 0; cli_list(c, mask, FILE_ATTRIBUTE_DIRECTORY, delete_fn, NULL); free(mask); cli_rmdir(c, dname); if (total_deleted) printf("WARNING: Cleaned up %d files\n", total_deleted); }
static NTSTATUS gpo_sync_files(struct sync_context *ctx) { NTSTATUS status; DEBUG(3,("calling cli_list with mask: %s\n", ctx->mask)); status = cli_list(ctx->cli, ctx->mask, ctx->attribute, gpo_sync_func, ctx); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("listing [%s] failed with error: %s\n", ctx->mask, nt_errstr(status))); return status; } return status; }
static NTSTATUS delete_fn(const char *mnt, struct file_info *finfo, const char *name, void *state) { NTSTATUS status; char *s, *n; if (finfo->name[0] == '.') { return NT_STATUS_OK; } n = SMB_STRDUP(name); n[strlen(n)-1] = 0; if (asprintf(&s, "%s%s", n, finfo->name) == -1) { free(n); printf("asprintf failed\n"); return NT_STATUS_NO_MEMORY; } if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) { char *s2; if (asprintf(&s2, "%s\\*", s) == -1) { printf("asprintf failed\n"); free(s); free(n); return NT_STATUS_NO_MEMORY; } status = cli_list(c, s2, FILE_ATTRIBUTE_DIRECTORY, delete_fn, NULL); free(s2); if (!NT_STATUS_IS_OK(status)) { free(s); free(n); return status; } nb_rmdir(s); } else { total_deleted++; nb_unlink(s); } free(s); free(n); return NT_STATUS_OK; }
void nb_findfirst(const char *mask) { cli_list(c, mask, 0, find_fn, NULL); }