TEST(cadastroTest, cadastroCheckRegexTest) { const char float_er[] = "[1-9][0-9]*\\.?[0-9]*([Ee][+-]?[0-9]+)?"; EXPECT_EQ(0, check_regex(float_er, "65000.00")); EXPECT_EQ(-1, check_regex(NULL, NULL)); }
int in_exclude_regex(struct strlist *excreg, const char *fname) { // If not doing exclude_regex, let the file get backed up. for(; excreg; excreg=excreg->next) if(check_regex(excreg->re, fname)) return 1; return 0; }
/* Currently not used - it needs more thinking about. */ int in_include_regex(struct strlist *increg, const char *fname) { // If not doing include_regex, let the file get backed up. if(!increg) return 1; for(; increg; increg=increg->next) if(check_regex(increg->re, fname)) return 1; return 0; }
static void st_collection_page_items_item_string_deny(void) { check_arg_count(1); current_item->spec.s.deny = parse_str(0); check_regex(current_item->spec.s.deny); }
static void st_collection_page_items_item_string_accept(void) { check_arg_count(1); current_item->spec.s.accept = parse_str(0); check_regex(current_item->spec.s.accept); }
/*This function read perform the fucll check, read map into vector, check if the map is valid. If it is, it returns true*/ bool MapHandler::map_is_valid(std::string filename){ if(!read_map(filename)){ return false; }else{ if(check_regex(filename)){ return true; }else{ return false; } } }
static int redir_handle_url(struct redir_t *redir, struct redir_conn_t *conn, struct redir_httpreq_t *httpreq, struct redir_socket_t *socket, struct sockaddr_in *peer, redir_request *req) { int port = 80; int matches = 1; int i = -1; char *p = 0; #ifdef ENABLE_REDIRINJECT char hasInject = 0; if (conn->s_params.flags & UAM_INJECT_URL) { safe_strncpy((char *) req->inject_url, (char *) conn->s_params.url, REDIRINJECT_MAX); hasInject = 1; } else if (_options.inject && *_options.inject) { safe_strncpy((char *) req->inject_url, (char *) _options.inject, REDIRINJECT_MAX); hasInject = 1; } else { #endif for (i=0; i < MAX_REGEX_PASS_THROUGHS; i++) { if ( ! _options.regex_pass_throughs[i].inuse ) break; /* if ( ! _options.regex_pass_throughs[i].regex_host[0] && ! _options.regex_pass_throughs[i].regex_path[0] && ! _options.regex_pass_throughs[i].regex_qs[0] ) break; */ #if(_debug_) log_dbg("REGEX host=[%s] path=[%s] qs=[%s]", _options.regex_pass_throughs[i].regex_host, _options.regex_pass_throughs[i].regex_path, _options.regex_pass_throughs[i].regex_qs); log_dbg("Host %s", httpreq->host); #endif if (_options.regex_pass_throughs[i].regex_host[0]) { switch(check_regex(&_options.regex_pass_throughs[i].re_host, _options.regex_pass_throughs[i].regex_host, httpreq->host)) { case -1: return -1; case 1: matches = _options.regex_pass_throughs[i].neg_host; break; case 0: matches = !_options.regex_pass_throughs[i].neg_host; break; } } if (matches && _options.regex_pass_throughs[i].regex_path[0]) { switch(check_regex(&_options.regex_pass_throughs[i].re_path, _options.regex_pass_throughs[i].regex_path, httpreq->path)) { case -1: return -1; case 1: matches = _options.regex_pass_throughs[i].neg_path; break; case 0: matches = !_options.regex_pass_throughs[i].neg_path; break; } } if (matches && _options.regex_pass_throughs[i].regex_qs[0]) { switch(check_regex(&_options.regex_pass_throughs[i].re_qs, _options.regex_pass_throughs[i].regex_qs, httpreq->qs)) { case -1: return -1; case 1: matches = _options.regex_pass_throughs[i].neg_qs; break; case 0: matches = !_options.regex_pass_throughs[i].neg_qs; break; } } if (matches) break; } #ifdef ENABLE_REDIRINJECT } #endif if (i == 0) matches = 0; if (matches) { log_dbg("Matched for Host %s", httpreq->host); req->proxy = 1; #ifdef ENABLE_REDIRINJECT /* XXX */ /* Check for headers we wish to filter out */ if (hasInject) { bstring newhdr = bfromcstr(""); char *hdr = (char *)req->wbuf->data; if (_options.inject_wispr) (void) inject_fmt(req, conn); while (hdr && *hdr) { char *p = strstr(hdr, "\r\n"); int skip = 0; int l; if (p) { l = (p - hdr); } else { l = req->wbuf->slen - (hdr - (char*)req->wbuf->data); } if (!strncasecmp(hdr, "accept-encoding:", 16)) { bcatcstr(newhdr, "Accept-Encoding: identity\r\n"); skip = 1; } else if (!strncasecmp(hdr, "connection:", 11)) { bcatcstr(newhdr, "Connection: close\r\n"); skip = 1; } else if (!strncasecmp(hdr, "keep-alive:", 11)) { skip = 1; } if (!skip) bcatblk(newhdr, hdr, l); if (p) { if (!skip) bcatblk(newhdr, p, 2); hdr = p + 2; } else { hdr = 0; } } if (req->wbuf->slen != newhdr->slen) { log_dbg("Changed HTTP Headers"); } bassign(req->wbuf, newhdr); bdestroy(newhdr); } /* XXX */ #endif if ((p = strchr(httpreq->host, ':'))) { *p++ = 0; port = atoi(p); } if (conn_setup(&req->conn, httpreq->host, port, req->wbuf, req->dbuf)) { log_err(errno, "conn_setup()"); return -1; } req->state |= REDIR_CONN_FD; net_select_addfd(&sctx, req->conn.sock, SELECT_READ); return 0; } return 1; }
static int list_manifest(struct asfd *asfd, const char *fullpath, regex_t *regex, const char *browsedir, struct conf *conf) { int ars=0; int ret=0; struct sbuf *sb=NULL; struct manio *manio=NULL; char *manifest_dir=NULL; char *last_bd_match=NULL; size_t bdlen=0; if(!(manifest_dir=prepend_s(fullpath, conf->protocol==PROTO_BURP1?"manifest.gz":"manifest")) || !(manio=manio_alloc()) || manio_init_read(manio, manifest_dir) || !(sb=sbuf_alloc(conf))) { log_and_send_oom(asfd, __func__); goto error; } manio_set_protocol(manio, conf->protocol); if(browsedir) bdlen=strlen(browsedir); while(1) { int show=0; if((ars=manio_sbuf_fill(manio, asfd, sb, NULL, NULL, conf))<0) goto error; else if(ars>0) goto end; // Finished OK. if(write_status(STATUS_LISTING, sb->path.buf, conf)) goto error; if(browsedir) { int r; if((r=check_browsedir(browsedir, &sb->path.buf, bdlen, &last_bd_match))<0) goto error; if(!r) continue; show++; } else { if(check_regex(regex, sb->path.buf)) show++; } if(show) { if(write_wrapper(asfd, &sb->attr) || write_wrapper(asfd, &sb->path)) goto error; if(sbuf_is_link(sb) && write_wrapper(asfd, &sb->link)) goto error; } sbuf_free_content(sb); } error: ret=-1; end: sbuf_free(&sb); free_w(&manifest_dir); manio_free(&manio); free_w(&last_bd_match); return ret; }
static void on_dialog_add_edit_reponse (GtkWidget *dialog, int response_id, LogviewFilterManager *manager) { GtkWidget *entry_name, *entry_regex; GtkWidget *radio_color, *radio_visible; GtkWidget *check_foreground, *check_background; GtkWidget *color_foreground, *color_background; gchar *old_name; const gchar *name; const gchar *regex; LogviewFilter *filter; GtkTextTag *tag; GtkBuilder *builder; old_name = g_object_get_data (G_OBJECT (manager), "old_name"); builder = manager->priv->builder; entry_name = GTK_WIDGET (gtk_builder_get_object (builder, "entry_name")); entry_regex = GTK_WIDGET (gtk_builder_get_object (builder, "entry_regex")); radio_color = GTK_WIDGET (gtk_builder_get_object (builder, "radio_color")); radio_visible = GTK_WIDGET (gtk_builder_get_object (builder, "radio_visible")); check_foreground = GTK_WIDGET (gtk_builder_get_object (builder, "check_foreground")); check_background = GTK_WIDGET (gtk_builder_get_object (builder, "check_background")); color_foreground = GTK_WIDGET (gtk_builder_get_object (builder, "color_foreground")); color_background = GTK_WIDGET (gtk_builder_get_object (builder, "color_background")); if (response_id == GTK_RESPONSE_APPLY) { name = gtk_entry_get_text (GTK_ENTRY (entry_name)); regex = gtk_entry_get_text (GTK_ENTRY (entry_regex)); if (!check_name (manager, name) || !check_regex (manager, regex)) { return; } filter = logview_filter_new (name, regex); tag = gtk_text_tag_new (name); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_color))) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_foreground))) { GdkColor foreground_color; gtk_color_button_get_color (GTK_COLOR_BUTTON (color_foreground), &foreground_color); g_object_set (G_OBJECT (tag), "foreground-gdk", &foreground_color, "foreground-set", TRUE, NULL); } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_background))) { GdkColor background_color; gtk_color_button_get_color (GTK_COLOR_BUTTON (color_background), &background_color); g_object_set (tag, "paragraph-background-gdk", &background_color, "paragraph-background-set", TRUE, NULL); } if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_foreground)) && !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_background))) { GtkWidget *error_dialog; error_dialog = gtk_message_dialog_new (GTK_WINDOW (manager), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", _("Please specify either foreground or background color!")); gtk_dialog_run (GTK_DIALOG (error_dialog)); gtk_widget_destroy (error_dialog); g_object_unref (tag); g_object_unref (filter); return; } } else { /* !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_color)) */ g_object_set (tag, "invisible", TRUE, NULL); } if (old_name && !g_str_equal (old_name, name)) { logview_prefs_remove_filter (manager->priv->prefs, old_name); } g_object_set (G_OBJECT (filter), "texttag", tag, NULL); g_object_unref (tag); logview_prefs_add_filter (manager->priv->prefs, filter); g_object_unref (filter); logview_filter_manager_update_model (manager); } gtk_widget_destroy (dialog); }
// a = length of struct bu array // i = position to restore from static int restore_manifest(struct bu *arr, int a, int i, const char *tmppath1, const char *tmppath2, regex_t *regex, int srestore, enum action act, const char *client, char **dir_for_notify, struct cntr *p1cntr, struct cntr *cntr, struct config *cconf) { int ret=0; gzFile zp=NULL; char *manifest=NULL; char *datadir=NULL; FILE *logfp=NULL; char *logpath=NULL; char *logpathz=NULL; // For sending status information up to the server. char status=STATUS_RESTORING; if(act==ACTION_RESTORE) status=STATUS_RESTORING; else if(act==ACTION_VERIFY) status=STATUS_VERIFYING; if( (act==ACTION_RESTORE && !(logpath=prepend_s(arr[i].path, "restorelog", strlen("restorelog")))) || (act==ACTION_RESTORE && !(logpathz=prepend_s(arr[i].path, "restorelog.gz", strlen("restorelog.gz")))) || (act==ACTION_VERIFY && !(logpath=prepend_s(arr[i].path, "verifylog", strlen("verifylog")))) || (act==ACTION_VERIFY && !(logpathz=prepend_s(arr[i].path, "verifylog.gz", strlen("verifylog.gz")))) || !(manifest=prepend_s(arr[i].path, "manifest.gz", strlen("manifest.gz")))) { log_and_send_oom(__FUNCTION__); ret=-1; } else if(!(logfp=open_file(logpath, "ab")) || set_logfp(logfp, cconf)) { char msg[256]=""; snprintf(msg, sizeof(msg), "could not open log file: %s", logpath); log_and_send(msg); ret=-1; } *dir_for_notify=strdup(arr[i].path); log_restore_settings(cconf, srestore); // First, do a pass through the manifest to set up the counters. // This is the equivalent of a phase1 scan during backup. if(!ret && !(zp=gzopen_file(manifest, "rb"))) { log_and_send("could not open manifest"); ret=-1; } else { int ars=0; int quit=0; struct sbuf sb; init_sbuf(&sb); while(!quit) { if((ars=sbuf_fill(NULL, zp, &sb, cntr))) { if(ars<0) ret=-1; // ars==1 means end ok quit++; } else { if((!srestore || check_srestore(cconf, sb.path)) && check_regex(regex, sb.path)) { do_filecounter(p1cntr, sb.cmd, 0); if(sb.endfile) do_filecounter_bytes(p1cntr, strtoull(sb.endfile, NULL, 10)); /* if(sb.cmd==CMD_FILE || sb.cmd==CMD_ENC_FILE || sb.cmd==CMD_METADATA || sb.cmd==CMD_ENC_METADATA || sb.cmd==CMD_VSS || sb.cmd==CMD_ENC_VSS || sb.cmd==CMD_VSS_T || sb.cmd==CMD_ENC_VSS_T || sb.cmd==CMD_EFS_FILE) do_filecounter_bytes(p1cntr, (unsigned long long) sb.statp.st_size); */ } } free_sbuf(&sb); } free_sbuf(&sb); gzclose_fp(&zp); } if(cconf->send_client_counters) { if(send_counters(client, p1cntr, cntr)) { ret=-1; } } // Now, do the actual restore. if(!ret && !(zp=gzopen_file(manifest, "rb"))) { log_and_send("could not open manifest"); ret=-1; } else { char cmd; int s=0; int quit=0; size_t len=0; struct sbuf sb; // For out-of-sequence directory restoring so that the // timestamps come out right: int scount=0; struct sbuf **sblist=NULL; init_sbuf(&sb); while(!quit) { int ars=0; char *buf=NULL; if(async_read_quick(&cmd, &buf, &len)) { logp("read quick error\n"); ret=-1; quit++; break; } if(buf) { //logp("got read quick\n"); if(cmd==CMD_WARNING) { logp("WARNING: %s\n", buf); do_filecounter(cntr, cmd, 0); free(buf); buf=NULL; continue; } else if(cmd==CMD_INTERRUPT) { // Client wanted to interrupt the // sending of a file. But if we are // here, we have already moved on. // Ignore. free(buf); buf=NULL; continue; } else { logp("unexpected cmd from client: %c:%s\n", cmd, buf); free(buf); buf=NULL; ret=-1; quit++; break; } } if((ars=sbuf_fill(NULL, zp, &sb, cntr))) { if(ars<0) ret=-1; // ars==1 means end ok quit++; } else { if((!srestore || check_srestore(cconf, sb.path)) && check_regex(regex, sb.path) && restore_ent(client, &sb, &sblist, &scount, arr, a, i, tmppath1, tmppath2, act, status, cconf, cntr, p1cntr)) { ret=-1; quit++; } } free_sbuf(&sb); } gzclose_fp(&zp); // Restore any directories that are left in the list. if(!ret) for(s=scount-1; s>=0; s--) { if(restore_sbuf(sblist[s], arr, a, i, tmppath1, tmppath2, act, client, status, p1cntr, cntr, cconf)) { ret=-1; break; } } free_sbufs(sblist, scount); if(!ret) ret=do_restore_end(act, cntr); //print_endcounter(cntr); print_filecounters(p1cntr, cntr, act); reset_filecounter(p1cntr, time(NULL)); reset_filecounter(cntr, time(NULL)); } set_logfp(NULL, cconf); compress_file(logpath, logpathz, cconf); if(manifest) free(manifest); if(datadir) free(datadir); if(logpath) free(logpath); if(logpathz) free(logpathz); return ret; }
static int list_manifest(const char *fullpath, regex_t *regex, const char *browsedir, const char *client, struct cntr *p1cntr, struct cntr *cntr) { int ars=0; int ret=0; int quit=0; gzFile zp=NULL; struct sbuf mb; char *manifest=NULL; size_t bdlen=0; init_sbuf(&mb); if(!(manifest=prepend_s(fullpath, "manifest.gz", strlen("manifest.gz")))) { log_and_send_oom(__FUNCTION__); return -1; } if(!(zp=gzopen_file(manifest, "rb"))) { log_and_send("could not open manifest"); free(manifest); return -1; } free(manifest); if(browsedir) bdlen=strlen(browsedir); while(!quit) { int show=0; //logp("list manifest loop\n"); // Need to parse while sending, to take note of the regex. free_sbuf(&mb); if((ars=sbuf_fill(NULL, zp, &mb, cntr))) { if(ars<0) ret=-1; // ars==1 means it ended ok. break; } if(mb.cmd!=CMD_DIRECTORY && mb.cmd!=CMD_FILE && mb.cmd!=CMD_ENC_FILE && mb.cmd!=CMD_EFS_FILE && mb.cmd!=CMD_SPECIAL && !cmd_is_link(mb.cmd)) continue; //if(mb.path[mb.plen]=='\n') mb.path[mb.plen]='\0'; write_status(client, STATUS_LISTING, mb.path, p1cntr, cntr); if(browsedir) { int r; if((r=check_browsedir(browsedir, &(mb.path), bdlen))<0) { quit++; ret=-1; } if(!r) continue; show++; } else { if(check_regex(regex, mb.path)) show++; } if(show) { if(async_write(CMD_STAT, mb.statbuf, mb.slen) || async_write(mb.cmd, mb.path, mb.plen)) { quit++; ret=-1; } else if(sbuf_is_link(&mb) && async_write(mb.cmd, mb.linkto, mb.llen)) { quit++; ret=-1; } } } gzclose_fp(&zp); free_sbuf(&mb); return ret; }
/* This function reads the manifest to determine whether it may be more efficient to just copy the data files across and unpack them on the other side. If it thinks it is, it will then do it. Return -1 on error, 1 if it copied the data across, 0 if it did not. */ static int maybe_copy_data_files_across(struct asfd *asfd, const char *manifest, const char *datadir, int srestore, regex_t *regex, struct conf *conf, struct slist *slist, enum action act, enum cstat_status status) { int ars; int ret=-1; struct sbuf *sb=NULL; struct blk *blk=NULL; struct manio *manio=NULL; uint64_t blkcount=0; uint64_t datcount=0; struct hash_weak *tmpw; struct hash_weak *hash_weak; uint64_t estimate_blks; uint64_t estimate_dats; uint64_t estimate_one_dat; int need_data=0; int last_ent_was_dir=0; char sig[128]=""; // If the client has no restore_spool directory, we have to fall back // to the stream style restore. if(!conf->restore_spool) return 0; if(!(manio=manio_alloc()) || manio_init_read(manio, manifest) || !(sb=sbuf_alloc(conf)) || !(blk=blk_alloc())) goto end; while(1) { if((ars=manio_sbuf_fill(manio, asfd, sb, blk, NULL, conf))<0) { logp("Error from manio_sbuf_fill() in %s\n", __func__); goto end; // Error; } else if(ars>0) break; // Finished OK. if(!blk->got_save_path) { sbuf_free_content(sb); continue; } if((!srestore || check_srestore(conf, sb->path.buf)) && check_regex(regex, sb->path.buf)) { blkcount++; if(!hash_weak_find((uint64_t)blk->savepath)) { if(!hash_weak_add((uint64_t)blk->savepath)) goto end; datcount++; } } sbuf_free_content(sb); } estimate_blks=blkcount*RABIN_AVG; estimate_one_dat=DATA_FILE_SIG_MAX*RABIN_AVG; estimate_dats=datcount*estimate_one_dat; printf("%lu blocks = %lu bytes in stream approx\n", blkcount, estimate_blks); printf("%lu data files = %lu bytes approx\n", datcount, estimate_dats); if(estimate_blks < estimate_one_dat) { printf("Stream is less than the size of a data file.\n"); printf("Use restore stream\n"); return 0; } else if(estimate_dats >= 90*(estimate_blks/100)) { printf("Stream is more than 90%% size of data files.\n"); printf("Use restore stream\n"); return 0; } else { printf("Data files are less than 90%% size of stream.\n"); printf("Use data files\n"); } printf("Client is using restore_spool: %s\n", conf->restore_spool); if(asfd->write_str(asfd, CMD_GEN, "restore_spool") || asfd->read_expect(asfd, CMD_GEN, "restore_spool_ok")) goto end; // Send each of the data files that we found to the client. HASH_ITER(hh, hash_table, hash_weak, tmpw) { char msg[32]; char path[32]; char *fdatpath=NULL; snprintf(path, sizeof(path), "%014lX", hash_weak->weak); path[4]='/'; path[9]='/'; snprintf(msg, sizeof(msg), "dat=%s", path); printf("got: %s\n", msg); if(asfd->write_str(asfd, CMD_GEN, msg)) goto end; if(!(fdatpath=prepend_s(datadir, path))) goto end; if(send_a_file(asfd, fdatpath, conf)) { free(fdatpath); goto end; } free(fdatpath); }
// a = length of struct bu array // i = position to restore from static int restore_manifest(struct bu *arr, int a, int i, const char *tmppath1, const char *tmppath2, regex_t *regex, enum action act, const char *client, struct cntr *p1cntr, struct cntr *cntr, struct config *cconf, bool all) { int ret=0; gzFile zp=NULL; char *manifest=NULL; char *datadir=NULL; FILE *logfp=NULL; char *logpath=NULL; char *logpathz=NULL; // For sending status information up to the server. char status=STATUS_RESTORING; if(act==ACTION_RESTORE) status=STATUS_RESTORING; else if(act==ACTION_VERIFY) status=STATUS_VERIFYING; if( (act==ACTION_RESTORE && !(logpath=prepend_s(arr[i].path, "restorelog", strlen("restorelog")))) || (act==ACTION_RESTORE && !(logpathz=prepend_s(arr[i].path, "restorelog.gz", strlen("restorelog.gz")))) || (act==ACTION_VERIFY && !(logpath=prepend_s(arr[i].path, "verifylog", strlen("verifylog")))) || (act==ACTION_VERIFY && !(logpathz=prepend_s(arr[i].path, "verifylog.gz", strlen("verifylog.gz")))) || !(manifest=prepend_s(arr[i].path, "manifest.gz", strlen("manifest.gz")))) { log_and_send("out of memory"); ret=-1; } else if(!(logfp=open_file(logpath, "ab")) || set_logfp(logfp)) { char msg[256]=""; snprintf(msg, sizeof(msg), "could not open log file: %s", logpath); log_and_send(msg); ret=-1; } else if(!(zp=gzopen_file(manifest, "rb"))) { log_and_send("could not open manifest"); ret=-1; } else { char cmd; int quit=0; size_t len=0; struct sbuf sb; // For out-of-sequence directory restoring so that the // timestamps come out right: int s=0; int scount=0; struct sbuf **sblist=NULL; init_sbuf(&sb); while(!quit) { int ars=0; char *buf=NULL; if(async_read_quick(&cmd, &buf, &len)) { logp("read quick error\n"); ret=-1; quit++; break; } if(buf) { //logp("got read quick\n"); if(cmd==CMD_WARNING) { logp("WARNING: %s\n", buf); do_filecounter(cntr, cmd, 0); free(buf); buf=NULL; continue; } else if(cmd==CMD_INTERRUPT) { // Client wanted to interrupt the // sending of a file. But if we are // here, we have already moved on. // Ignore. free(buf); buf=NULL; continue; } else { logp("unexpected cmd from client: %c:%s\n", cmd, buf); free(buf); buf=NULL; ret=-1; quit++; break; } } if((ars=sbuf_fill(NULL, zp, &sb, cntr))) { if(ars<0) ret=-1; // ars==1 means end ok quit++; } else { if(check_regex(regex, sb.path)) { // Check if we have any directories waiting // to be restored. for(s=scount-1; s>=0; s--) { if(is_subdir(sblist[s]->path, sb.path)) { // We are still in a subdir. //printf(" subdir (%s %s)\n", sblist[s]->path, sb.path); break; } else { // Can now restore sblist[s] // because nothing else is // fiddling in a subdirectory. if(restore_sbuf(sblist[s], arr, a, i, tmppath1, tmppath2, act, client, status, p1cntr, cntr, cconf)) { ret=-1; quit++; break; } else if(del_from_sbuf_arr( &sblist, &scount)) { ret=-1; quit++; break; } } } /* If it is a directory, need to remember it and restore it later, so that the permissions come out right. */ /* Meta data of directories will also have the stat stuff set to be a directory, so will also come out at the end. */ if(!ret && S_ISDIR(sb.statp.st_mode)) { if(add_to_sbuf_arr(&sblist, &sb, &scount)) { ret=-1; quit++; } // Wipe out sb, without freeing up // all the strings inside it, which // have been added to sblist. init_sbuf(&sb); } else if(!ret && restore_sbuf(&sb, arr, a, i, tmppath1, tmppath2, act, client, status, p1cntr, cntr, cconf)) { ret=-1; quit++; } } } free_sbuf(&sb); } gzclose_fp(&zp); // Restore any directories that are left in the list. if(!ret) for(s=scount-1; s>=0; s--) { if(restore_sbuf(sblist[s], arr, a, i, tmppath1, tmppath2, act, client, status, p1cntr, cntr, cconf)) { ret=-1; break; } } free_sbufs(sblist, scount); if(!ret && !all) ret=do_restore_end(act, cntr); print_endcounter(cntr); print_filecounters(p1cntr, cntr, act, 0); reset_filecounter(p1cntr); reset_filecounter(cntr); } set_logfp(NULL); compress_file(logpath, logpathz, cconf); if(manifest) free(manifest); if(datadir) free(datadir); if(logpath) free(logpath); if(logpathz) free(logpathz); return ret; }
static bool check_configFilename(const char *filename){ const std::string s(filename); const std::string pattern("^.*\\.json$"); return check_regex(s,pattern); }
static bool check_filename(const char *filename){ const std::string s(filename); const std::string pattern("^[[:alnum:]]*\\.\\(jpg|png|html|js|css\\)$"); return check_regex(s,pattern); }
int want_to_restore(int srestore, struct sbuf *sb, regex_t *regex, struct conf **cconfs) { return (!srestore || check_srestore(cconfs, sb->path.buf)) && check_regex(regex, sb->path.buf); }