void cmd_source(int argc, char **argv) { int i; OPT_HELP_NEW(_("Read (source) a configuration file."), "source [options] <file>...", NULL); minargs(optind); for(i = optind; i < argc; i++) parse_rc(argv[i], true); init_ftp(); }
void cmd_source(int argc, char **argv) { int i; OPT_HELP("Read (source) a configuration file. Usage:\n" " source [options] <file>...\n" "Options:\n" " -h, --help show this help\n"); minargs(optind); for(i = optind; i < argc; i++) parse_rc(argv[i], true); init_ftp(); }
int interface_capture (SDL_Surface *screen, int w, int h) {{{ const char *extension[]={".jpeg",".png",".bmp"}; /* This function is called to take a picure from the cam * and save it to a file */ char *capture_filename; SDL_Surface *tmp_surface; struct stat file_stat; int file_size = -1; /* Get a free filename */ capture_filename = getNewFilename (Dump_Path(), Dump_Prefix(), extension [configuration.dump_mode]); if (NULL == capture_filename) return -1; /* Capture the image*/ tmp_surface = get_ImageSurface(screen, w, h); /* {{{ Write image */ { unsigned char *data; int i; unsigned char tmp; data = (unsigned char*)tmp_surface->pixels; if ( SDL_MUSTLOCK(screen) ) { if ( SDL_LockSurface(screen) < 0 ) { fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError()); free (capture_filename); return -1; } } /* swap Red and blue */ for (i=0; i<tmp_surface->w*tmp_surface->h*3; i+=3) { tmp = data[i]; data[i] = data[i+2]; data[i+2] = tmp; } if ( SDL_MUSTLOCK (screen) ) { SDL_UnlockSurface (screen); } switch (configuration.dump_mode) { case 0: write_file_jpeg (capture_filename, (unsigned char*)tmp_surface->pixels, tmp_surface->w, tmp_surface->h); break; case 1: write_file_png (capture_filename, (unsigned char*)tmp_surface->pixels, (unsigned int)tmp_surface->w, (unsigned int)tmp_surface->h); break; case 2: SDL_SaveBMP(tmp_surface, capture_filename); break; default: fprintf(stderr, "Unsuported capture format.\n"); break; } } /* }}} */ SDL_FreeSurface(tmp_surface); // if (configuration.debug > 0) printf("Saved file: %s\n", capture_filename); /* {{{ FTP-Stuff */ if( configuration.ftp_host !=NULL && configuration.ftp_user !=NULL && configuration.ftp_pass !=NULL && configuration.ftp_file !=NULL ) { if (init_ftp (configuration.ftp_host, configuration.ftp_user, configuration.ftp_pass)) { if (configuration.debug > 0) printf ("Starte FTP Upload\n"); if (configuration.ftp_temp != NULL) { if (configuration.debug > 0) printf ("Using FTP Rename Method\n"); if (ftp_send (capture_filename, configuration.ftp_temp)) ftp_rename (configuration.ftp_temp, configuration.ftp_file); } else ftp_send (capture_filename, configuration.ftp_file); } } /* }}} */ if (!stat (capture_filename, &file_stat)) { file_size = file_stat.st_size; } free (capture_filename); return file_size; }}}