int uget_option_value_has_ctrl (UgetOptionValue* value) { if (mem_is_zero ((char*) &value->ctrl, sizeof (value->ctrl)) == FALSE) return TRUE; else return FALSE; }
static int verify_trimmed_io_u(struct thread_data *td, struct io_u *io_u) { size_t offset; if (!td->o.trim_zero) return 0; if (mem_is_zero(io_u->buf, io_u->buflen)) return 0; mem_is_zero_slow(io_u->buf, io_u->buflen, &offset); log_err("trim: verify failed at file %s offset %llu, length %lu" ", block offset %lu\n", io_u->file->file_name, io_u->offset, io_u->buflen, (unsigned long) offset); return EILSEQ; }
int uget_option_value_to_info (UgetOptionValue* ivalue, UgInfo* info) { union { UgetCommon* common; UgetProxy* proxy; UgetHttp* http; UgetFtp* ftp; } temp; if (mem_is_zero ((char*) &ivalue->common, sizeof (ivalue->common)) == FALSE) { temp.common = ug_info_realloc (info, UgetCommonInfo); temp.common->keeping.enable = TRUE; if (ivalue->common.folder) { ug_free (temp.common->folder); temp.common->folder = ivalue->common.folder; temp.common->keeping.folder = TRUE; ivalue->common.folder = NULL; } if (ivalue->common.file) { ug_free (temp.common->file); temp.common->file = ivalue->common.file; temp.common->keeping.file = TRUE; ivalue->common.file = NULL; } if (ivalue->common.user) { ug_free (temp.common->user); temp.common->user = ivalue->common.user; temp.common->keeping.user = TRUE; ivalue->common.user = NULL; } if (ivalue->common.password) { ug_free (temp.common->password); temp.common->password = ivalue->common.password; temp.common->keeping.password = TRUE; ivalue->common.password = NULL; } } if (mem_is_zero ((char*) &ivalue->proxy, sizeof (ivalue->proxy)) == FALSE) { temp.proxy = ug_info_realloc (info, UgetProxyInfo); temp.proxy->keeping.enable = TRUE; if (ivalue->proxy.type) { temp.proxy->type = ivalue->proxy.type; temp.proxy->keeping.type = TRUE; ivalue->proxy.type = 0; } if (ivalue->proxy.host) { ug_free (temp.proxy->host); temp.proxy->host = ivalue->proxy.host; temp.proxy->keeping.host = TRUE; ivalue->proxy.host = NULL; } if (ivalue->proxy.port) { temp.proxy->port = ivalue->proxy.port; temp.proxy->keeping.port = TRUE; ivalue->proxy.port = 0; } if (ivalue->proxy.user) { ug_free (temp.proxy->user); temp.proxy->user = ivalue->proxy.user; temp.proxy->keeping.user = TRUE; ivalue->proxy.user = NULL; } if (ivalue->proxy.password) { ug_free (temp.proxy->password); temp.proxy->password = ivalue->proxy.password; temp.proxy->keeping.password = TRUE; ivalue->proxy.password = NULL; } } if (mem_is_zero ((char*) &ivalue->http, sizeof (ivalue->http)) == FALSE) { temp.http = ug_info_realloc (info, UgetHttpInfo); temp.http->keeping.enable = TRUE; if (ivalue->http.user) { ug_free (temp.http->user); temp.http->user = ivalue->http.user; temp.http->keeping.user = TRUE; ivalue->http.user = NULL; } if (ivalue->http.password) { ug_free (temp.http->password); temp.http->password = ivalue->http.password; temp.http->keeping.password = TRUE; ivalue->http.password = NULL; } if (ivalue->http.referrer) { ug_free (temp.http->referrer); temp.http->referrer = ivalue->http.referrer; temp.http->keeping.referrer = TRUE; ivalue->http.referrer = NULL; } if (ivalue->http.user_agent) { ug_free (temp.http->user_agent); temp.http->user_agent = ivalue->http.user_agent; temp.http->keeping.user_agent = TRUE; ivalue->http.user_agent = NULL; } if (ivalue->http.cookie_data) { ug_free (temp.http->cookie_data); temp.http->cookie_data = ivalue->http.cookie_data; temp.http->keeping.cookie_data = TRUE; ivalue->http.cookie_data = NULL; } if (ivalue->http.cookie_file) { ug_free (temp.http->cookie_file); temp.http->cookie_file = ivalue->http.cookie_file; temp.http->keeping.cookie_file = TRUE; ivalue->http.cookie_file = NULL; } if (ivalue->http.post_data) { ug_free (temp.http->post_data); temp.http->post_data = ivalue->http.post_data; temp.http->keeping.post_data = TRUE; ivalue->http.post_data = NULL; } if (ivalue->http.post_file) { ug_free (temp.http->post_file); temp.http->post_file = ivalue->http.post_file; temp.http->keeping.post_file = TRUE; ivalue->http.post_file = NULL; } } if (mem_is_zero ((char*) &ivalue->ftp, sizeof (ivalue->ftp)) == FALSE) { temp.ftp = ug_info_realloc (info, UgetFtpInfo); temp.ftp->keeping.enable = TRUE; if (ivalue->ftp.user) { ug_free (temp.ftp->user); temp.ftp->user = ivalue->ftp.user; temp.ftp->keeping.user = TRUE; ivalue->ftp.user = NULL; } if (ivalue->ftp.password) { ug_free (temp.ftp->password); temp.ftp->password = ivalue->ftp.password; temp.ftp->keeping.password = TRUE; ivalue->ftp.password = NULL; } } return TRUE; }
/* * sscript_save - save a script lump to file */ int sscript_save(struct WADINFO *wad, int16_t n, const char *file) { FILE *fp = NULL; unsigned char *data = NULL; int32_t size = 0; const char *lumpname = wad->dir[n].name; data = (unsigned char *) WADRreadEntry(wad, n, &size); if (size % PAGESZ) { Warning("SS10", "script %s: weird size %ld", lump_name(lumpname), (long) size); size = PAGESZ * (size / PAGESZ); } fp = fopen(file, "w"); if (fp == NULL) { nf_err("SS15", "%s: %s", file, strerror(errno)); return 1; } fprintf(fp, "# DeuTex Strife script source version 1\n"); /* Save all pages */ { int p; for (p = 0; p < size / PAGESZ; p++) { unsigned long ofs = PAGESZ * p; int o; fputc('\n', fp); fprintf(fp, "page %d {\n", p); dump_field(fp, data, &ofs, FT_I32, " unknown0 "); dump_field(fp, data, &ofs, FT_I32, " unknown1 "); dump_field(fp, data, &ofs, FT_I32, " unknown2 "); dump_field(fp, data, &ofs, FT_I32, " unknown3 "); dump_field(fp, data, &ofs, FT_I32, " unknown4 "); dump_field(fp, data, &ofs, FT_I32, " unknown5 "); dump_field(fp, data, &ofs, FT_S16, " character "); dump_field(fp, data, &ofs, FT_NAME, " voice "); dump_field(fp, data, &ofs, FT_NAME, " background "); dump_field(fp, data, &ofs, FT_S320, " statement "); for (o = 0; o < 5; o++) { /* If the option is zeroed out, omit it */ if (mem_is_zero((char *) (data + ofs), OPTIONSZ)) { ofs += OPTIONSZ; continue; } /* Else, decode it */ fputc('\n', fp); fprintf(fp, " option %d {\n", o); dump_field(fp, data, &ofs, FT_I32, " whata "); dump_field(fp, data, &ofs, FT_I32, " whatb "); dump_field(fp, data, &ofs, FT_I32, " whatc "); dump_field(fp, data, &ofs, FT_I32, " whatd "); dump_field(fp, data, &ofs, FT_I32, " whate "); dump_field(fp, data, &ofs, FT_I32, " price "); dump_field(fp, data, &ofs, FT_I32, " whatg "); dump_field(fp, data, &ofs, FT_S32, " option "); dump_field(fp, data, &ofs, FT_S80, " success "); dump_field(fp, data, &ofs, FT_I32, " whath "); dump_field(fp, data, &ofs, FT_I32, " whati "); dump_field(fp, data, &ofs, FT_S80, " failure "); fputs(" }\n", fp); } fputs("}\n", fp); /* Sanity check */ if (ofs % PAGESZ) Bug("SS20", "script %s: page %d: bad script offset %d", lump_name(lumpname), p, (int) ofs); } } free(data); if (fclose(fp)) { nf_err("SS45", "%s: %s", file, strerror(errno)); return 1; } return 0; }