void process_img_all(void) { DIR *dp; struct dirent *dentp; struct stat sb; int len, ret, nfiles = 0; char *ext; if ((dp = opendir(".")) == NULL) { printf("Access denied to current directory!\n"); return; } while ((dentp = readdir(dp)) != NULL) { if (strcmp(dentp->d_name, ".") == 0 || strcmp(dentp->d_name, "..") == 0) continue; if (stat(dentp->d_name, &sb) != 0 || !S_ISREG(sb.st_mode)) continue; len = strlen(dentp->d_name); if (len < 5) continue; if (len >= 5 && dentp->d_name[len - 4] == '.') ext = &dentp->d_name[len - 3]; else if (len >= 6 && dentp->d_name[len - 5] == '.') ext = &dentp->d_name[len - 4]; else continue; if (strcasecmp(ext, "png") == 0) { if (nfiles++ == 0 && !g_verbose) status_header(); ret = process_image_png(dentp->d_name); if (!g_verbose && ret) status_line(dentp->d_name, ret); } else if (strcasecmp(ext, "jpg") == 0 || strcasecmp(ext, "jpeg") == 0) { if (nfiles++ == 0 && !g_verbose) status_header(); ret = process_image_jpg(dentp->d_name); if (!g_verbose && ret) status_line(dentp->d_name, ret); } } if (nfiles == 0) printf("No files found\n"); }
void process_img_all(void) { WIN32_FIND_DATA finddata; HANDLE hFind; int len, ret, nfiles = 0; char *ext; hFind = FindFirstFile("*", &finddata); if (hFind == INVALID_HANDLE_VALUE) { printf("No files found\n"); return; } do { if ( (finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || (finddata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) || (finddata.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) ) continue; len = strlen(finddata.cFileName); if (len < 5) continue; if (len >= 5 && finddata.cFileName[len - 4] == '.') ext = &finddata.cFileName[len - 3]; else if (len >= 6 && finddata.cFileName[len - 5] == '.') ext = &finddata.cFileName[len - 4]; else continue; if (strcasecmp(ext, "png") == 0) { if (nfiles++ == 0 && !g_verbose) status_header(); ret = process_image_png(finddata.cFileName); if (!g_verbose && ret) status_line(finddata.cFileName, ret); } else if (strcasecmp(ext, "jpg") == 0 || strcasecmp(ext, "jpeg") == 0) { if (nfiles++ == 0 && !g_verbose) status_header(); ret = process_image_jpg(finddata.cFileName); if (!g_verbose && ret) status_line(finddata.cFileName, ret); } } while (FindNextFile(hFind, &finddata)); FindClose(hFind); if (nfiles == 0) printf("No files found\n"); }
Response::Response(const char *stream, std::size_t size) : status_code_(0), status_code_type_(0), http_version_(0), reason_phrase_(), content_buffer_() { try { assert(stream); StatusLine status_line(stream, stream + size); status_code_ = status_line.GetStatusCode(); status_code_type_ = status_line.GetStatusCodeType(); http_version_ = status_line.GetHttpVersion(); reason_phrase_ = status_line.GetReasonPhrase(); ContentLocator locator(stream, size); const char *content_begin_pos = locator.GetContentBeginPos(); std::size_t content_length = locator.GetContentLength(); content_buffer_.assign(content_begin_pos, content_begin_pos + content_length); } catch (...) { throw ResponseException(std::string(stream, size)); } }
void check_duplicate_key (word keyno) { // int fd; activation_key (); if (registered && serial_no == keyno) { status_line ("!Duplicate key detected"); modem_hangup (); /* memset (config, 0, sizeof (struct _configuration)); fd = open (config_file, O_WRONLY|O_BINARY); write (fd, config, sizeof (struct _configuration)); close (fd); fclose (logf); logf = fopen ("SECURITY.CHK", "at"); status_line ("!Security breach"); fclose (logf); _dos_setfileattr ("SECURITY.CHK", _A_RDONLY|_A_HIDDEN|_A_SYSTEM); */ } }
int main(int argc,char *argv[]) { Fl_Socket socket; sock = &socket; Fl_Window main_window(600,400,"Socket test"); Fl_Group top_group(0,0,200,25); top_group.layout_align(FL_ALIGN_TOP); Fl_Box progress_text(0,0,150,25); p_text = &progress_text; Fl_ProgressBar progress_bar(150,0,50,25); p_bar = &progress_bar; top_group.resizable(p_bar); top_group.store_sizes(); top_group.end(); Fl_Text_Buffer buf; Fl_Text_Editor editor(10,10,200,100); editor.layout_align(FL_ALIGN_CLIENT); editor.buffer(buf); textbuf = &buf; textdisp = &editor; Fl_Group status_line(0,0,200,25); status_line.layout_align(FL_ALIGN_BOTTOM); Fl_Input url_input(50, 0, 100, 25, "http://"); url_input.value("www.fltk.org/index.php"); Fl_Button go_button(150, 0, 50, 25, "Go!"); go_button.callback(go_callback); status_line.resizable(url_input); status_line.store_sizes(); status_line.end(); input = &url_input; main_window.end(); main_window.resizable(main_window); main_window.show(argc,argv); return Fl::run(); }
void handle_change() { int fd=0; char stringa[40], filename[80]; long crc, ici; struct _usridx usridx; read_system_file ("ALIASASK"); strcpy (stringa, usr.handle); m_print(bbstxt[B_ALIAS_CHANGE]); chars_input (stringa, 35, INPUT_FANCY|INPUT_UPDATE|INPUT_FIELD); if (stringa[0] && stricmp (stringa, usr.name)) { crc = crc_name (stringa); sprintf (filename, "%s.IDX", config->user_file); fd = open (filename, O_RDWR|O_BINARY|O_CREAT, S_IREAD|S_IWRITE); while (read (fd, &usridx, sizeof (struct _usridx)) == sizeof (struct _usridx)) { if (usridx.id == crc || usridx.alias_id == crc) { status_line (":Invalid alias '%s'", stringa); stringa[0] = '\0'; break; } } close (fd); } if (stringa[0]){ strcpy (usr.handle, fancy_str (stringa)); usr.alias_id = crc; sprintf (filename, "%s.IDX", config->user_file); fd = open (filename, O_RDWR|O_BINARY|O_CREAT, S_IREAD|S_IWRITE); while (read (fd, &usridx, sizeof (struct _usridx)) == sizeof (struct _usridx)) { ici=tell(fd); if (usridx.id == usr.id) { lseek(fd,(ici-(sizeof(struct _usridx))),SEEK_SET); usridx.alias_id = crc; write (fd, (char *)&usridx, sizeof (struct _usridx)); break; } } close (fd); } }
std::string status_line(const char* version, http_error_code ec) { return status_line(std::string(version), ec); }
int main(int argc, char **argv) { int i, opt, ret; while ((opt = gumbo_getopt(argc, argv, ":h?v")) != -1) { switch (opt) { case '?': case 'h': imginf_help(); return 1; case 'v': g_verbose = 1; break; default: printf("imginf: Incorrect usage (%c)\n", Optopt); imginf_help(); } } for (i = Optind; i < argc; i++) { ret = file_seems_valid(argv[i]); if (!ret) { printf("Invalid file argument: %s\n", argv[i]); return 2; } } if (Optind == argc) { process_img_all(); return 0; } /* Process each image on the command line. No wildcards are allowed */ if (!g_verbose) status_header(); for (i = Optind; i < argc; i++) { ret = file_seems_valid(argv[i]); if (ret == 1) { ret = process_image_png(argv[i]); if (!g_verbose && ret) status_line(argv[i], ret); } else if (ret == 2) { ret = process_image_jpg(argv[i]); if (!g_verbose && ret) status_line(argv[i], ret); } } return 0; }