CmdLine::CmdLine(int argc,char**argv) : should_exit_(false) { po::options_description general("General options"); general.add_options() ("directories,d", po::value< std::vector<std::string> >(&dirs_),"directories to display on video") ("captions,c", po::value< std::vector<std::string> >(&captions_),"captions to display on videos (in the same order as directories)") ("output-directory,o", po::value<std::string>(&output_dir_),"output directory where the concatenated images are stored") ("verbose,v", "verbose mode") ("debug,D", "debug mode") ("help", "produce help message") ; prog_args.add(general); po::store(po::parse_command_line(argc, argv, prog_args), vm_); po::notify(vm_); if (vm_.count("help")) { std::cout << prog_args << std::endl; should_exit_ = true; } DEBUG_WRITE("Debug mode active."); unsigned int nbvid=0; std::string cur_caption(""); for(std::vector< std::string >::iterator i=dirs_.begin(), cap_iter=captions_.begin(); i!=dirs_.end(); i++,nbvid++){ if(cap_iter==captions_.end()) cur_caption = ""; else{ cur_caption = *cap_iter; cap_iter++; } boost::shared_ptr<VideoWithCaption> el(new VideoWithCaption()); el->caption=cur_caption; el->path = i->c_str(); el->reader.setFileName( i->c_str() ); el->reader.setFirstFrameIndex(0); el->reader.open(el->I); videos_.push_back(el); if(get_verbose()){ std::cout << "Adding video with path " << el->path << " and caption " << el->caption << std::endl; } } DEBUG_WRITE("Done adding videos."); if(get_verbose()) std::cout << nbvid << " videos added." << std::endl; }
static dvd_reader_t *DVDOpenPath( const char *path_root ) { dvd_reader_t *dvd; dvd = (dvd_reader_t *) malloc( sizeof( dvd_reader_t ) ); if( !dvd ) { return NULL; } dvd->verbose = get_verbose(); dvd->isImageFile = 0; dvd->dev = 0; dvd->path_root = strdup( path_root ); if(!dvd->path_root) { free(dvd); return 0; } dvd->udfcache_level = DEFAULT_UDF_CACHE_LEVEL; dvd->udfcache = NULL; dvd->align = NULL; dvd->css_state = 0; /* Only used in the UDF path */ dvd->css_title = 0; /* Only matters in the UDF path */ return dvd; }
/** * Open a DVD image or block device file. * Checks if the root directory in the udf image file can be found. * If not it assumes this isn't a valid udf image and returns NULL */ static dvd_reader_t *DVDOpenImageFile( const char *location, int have_css ) { dvd_reader_t *dvd; dvd_input_t dev; int verbose; verbose = get_verbose(); dev = dvdinput_open( location ); if( !dev ) { if(verbose >= 1) { fprintf( stderr, "libdvdread: Can't open '%s' for reading: %s\n", location, strerror(errno)); } return NULL; } dvd = (dvd_reader_t *) malloc( sizeof( dvd_reader_t ) ); if( !dvd ) { int tmp_errno = errno; dvdinput_close(dev); errno = tmp_errno; return NULL; } dvd->verbose = verbose; dvd->isImageFile = 1; dvd->dev = dev; dvd->path_root = NULL; dvd->udfcache_level = DEFAULT_UDF_CACHE_LEVEL; dvd->udfcache = NULL; dvd->align = NULL; if( have_css ) { /* Only if DVDCSS_METHOD = title, a bit if it's disc or if * DVDCSS_METHOD = key but region missmatch. Unfortunaly we * don't have that information. */ dvd->css_state = 1; /* Need key init. */ } dvd->css_title = 0; /* sanity check, is it a valid UDF image, can we find the root dir */ if(!UDFFindFile(dvd, "/", NULL)) { dvdinput_close(dvd->dev); if(dvd->udfcache) { FreeUDFCache(dvd, dvd->udfcache); } if(dvd->align) { if(dvd->verbose >= 0) { fprintf(stderr, "libdvdread: DVDOpenImageFile(): Memory leak in align functions 1\n"); } } free(dvd); return NULL; } return dvd; }
long __declspec(dllexport) WINAPI _get_verbose(lprec *lp) { long ret; if (lp != NULL) { freebuferror(); ret = get_verbose(lp); } else ret = 0; return(ret); }
static void parse_args (int argc, char **argv) { int i; for (i = 1; i < argc; i++) { if(strcmp (argv[i], "-h") == 0) { usage (argc, argv); exit (-1); } else if (strcmp (argv[i], "-v") == 0) { printf("Verbose mode turned on\n"); (*get_verbose()) = 1; } } }
void parser_imp::updt_options() { m_verbose = get_verbose(m_io_state.get_options()); m_show_errors = get_parser_show_errors(m_io_state.get_options()); }
dvd_reader_t *DVDOpen( const char *path ) { struct stat fileinfo; int ret, have_css; char *dev_name = NULL; int internal_errno = 0; int verbose; if( path == NULL ) { errno = EINVAL; return NULL; } verbose = get_verbose(); #ifdef WIN32 /* Stat doesn't work on devices under mingwin/cygwin. */ if( path[0] && path[1] == ':' && path[2] == '\0' ) { /* Don't try to stat the file */ fileinfo.st_mode = S_IFBLK; } else #endif { ret = stat( path, &fileinfo ); if( ret < 0 ) { int tmp_errno = errno; /* If we can't stat the file, give up */ if(verbose >= 1) { fprintf( stderr, "libdvdread: Can't stat '%s': %s\n", path, strerror(errno)); } errno = tmp_errno; return NULL; } } /* Try to open libdvdcss or fall back to standard functions */ have_css = dvdinput_setup(); /* First check if this is a block/char device or a file*/ if( S_ISBLK( fileinfo.st_mode ) || S_ISCHR( fileinfo.st_mode ) || S_ISREG( fileinfo.st_mode ) ) { /** * Block devices and regular files are assumed to be DVD-Video images. */ dvd_reader_t *dvd = NULL; #if defined(__sun) dev_name = sun_block2char( path ); #elif defined(SYS_BSD) dev_name = bsd_block2char( path ); #else dev_name = strdup( path ); #endif dvd = DVDOpenImageFile( dev_name, have_css ); free( dev_name ); return dvd; } else if( S_ISDIR( fileinfo.st_mode ) ) { dvd_reader_t *auth_drive = 0; char *path_copy; #if defined(SYS_BSD) struct fstab* fe; #elif defined(__sun) || defined(__linux__) || defined(__CYGWIN__) FILE *mntfile; #endif /* XXX: We should scream real loud here. */ if( !(path_copy = strdup( path ) ) ) return 0; #ifndef WIN32 /* don't have fchdir, and getcwd( NULL, ... ) is strange */ /* Resolve any symlinks and get the absolut dir name. */ { char *new_path; char *current_path; current_path = malloc(PATH_MAX); if(current_path) { if(!getcwd(current_path, PATH_MAX)) { free(current_path); current_path = NULL; } } if(current_path) { chdir( path_copy ); new_path = malloc(PATH_MAX); if(new_path) { if(!getcwd(new_path, PATH_MAX )) { free(new_path); new_path = NULL; } } chdir(current_path); free(current_path); if( new_path ) { free( path_copy ); path_copy = new_path; } } } #endif /** * If we're being asked to open a directory, check if that directory * is the mountpoint for a DVD-ROM which we can use instead. */ if( strlen( path_copy ) > 1 ) { if( path_copy[ strlen( path_copy ) - 1 ] == '/' ) { path_copy[ strlen( path_copy ) - 1 ] = '\0'; } } if( strlen( path_copy ) >= 9 ) { if( !strcasecmp( &(path_copy[ strlen( path_copy ) - 9 ]), "/video_ts" ) ) { path_copy[ strlen( path_copy ) - 9 ] = '\0'; if(path_copy[0] == '\0') { path_copy[0] = '/'; path_copy[1] = '\0'; } } } #if defined(SYS_BSD) if( ( fe = getfsfile( path_copy ) ) ) { dev_name = bsd_block2char( fe->fs_spec ); if(verbose >= 1) { fprintf( stderr, "libdvdread: Attempting to use device %s" " mounted on %s%s\n", dev_name, fe->fs_file, have_css ? " for CSS authentication" : ""); } auth_drive = DVDOpenImageFile( dev_name, have_css ); if(!auth_drive) { internal_errno = errno; } } #elif defined(__sun) mntfile = fopen( MNTTAB, "r" ); if( mntfile ) { struct mnttab mp; int res; while( ( res = getmntent( mntfile, &mp ) ) != -1 ) { if( res == 0 && !strcmp( mp.mnt_mountp, path_copy ) ) { dev_name = sun_block2char( mp.mnt_special ); if(verbose >= 1) { fprintf( stderr, "libdvdread: Attempting to use device %s" " mounted on %s%s\n", dev_name, mp.mnt_mountp, have_css ? " for CSS authentication" : ""); } auth_drive = DVDOpenImageFile( dev_name, have_css ); if(!auth_drive) { internal_errno = errno; } break; } } fclose( mntfile ); } #elif defined(__linux__) || defined(__CYGWIN__) mntfile = fopen( MOUNTED, "r" ); if( mntfile ) { struct mntent *me; while( ( me = getmntent( mntfile ) ) ) { if( !strcmp( me->mnt_dir, path_copy ) ) { if(verbose >= 1) { fprintf( stderr, "libdvdread: Attempting to use device %s" " mounted on %s%s\n", me->mnt_fsname, me->mnt_dir, have_css ? " for CSS authentication" : ""); } auth_drive = DVDOpenImageFile( me->mnt_fsname, have_css ); if(!auth_drive) { internal_errno = errno; } dev_name = strdup(me->mnt_fsname); break; } } fclose( mntfile ); } #elif defined(__MINGW32__) dev_name = strdup(path); auth_drive = DVDOpenImageFile( path, have_css ); #endif if( !dev_name ) { if(verbose >= 1) { fprintf( stderr, "libdvdread: Couldn't find device name.\n" ); } } else if( !auth_drive ) { if(verbose >= 1) { fprintf( stderr, "libdvdread: Device %s inaccessible%s: %s\n", dev_name, have_css ? ", CSS authentication not available" : "", strerror(internal_errno)); } } free( dev_name ); free( path_copy ); /** * If we've opened a drive, just use that. */ if( auth_drive ) { return auth_drive; } /** * Otherwise, we now try to open the directory tree instead. */ return DVDOpenPath( path ); } /* If it's none of the above, screw it. */ if(verbose >= 1) { fprintf( stderr, "libdvdread: Could not open %s\n", path ); } return 0; }
/** * Setup read functions with either libdvdcss or minimal DVD access. */ int dvdinput_setup(void) { char **dvdcss_version = NULL; int verbose; /* dlopening libdvdcss */ if(dvdcss_library_init) { /* libdvdcss is already dlopened, function ptrs set */ if(dvdcss_library) { return 1; /* css available */ } else { return 0; /* css not available */ } } verbose = get_verbose(); #ifdef HAVE_DVDCSS_DVDCSS_H /* linking to libdvdcss */ dvdcss_library = &dvdcss_library; /* Give it some value != NULL */ /* the DVDcss_* functions have been #defined at the top */ dvdcss_version = &dvdcss_interface_2; #else dvdcss_library = dlopen("libdvdcss.so.2", RTLD_LAZY); if(dvdcss_library != NULL) { #if defined(__OpenBSD__) && !defined(__ELF__) #define U_S "_" #else #define U_S #endif DVDcss_open = (dvdcss_handle (*)(const char*)) dlsym(dvdcss_library, U_S "dvdcss_open"); DVDcss_close = (int (*)(dvdcss_handle)) dlsym(dvdcss_library, U_S "dvdcss_close"); DVDcss_title = (int (*)(dvdcss_handle, int)) dlsym(dvdcss_library, U_S "dvdcss_title"); DVDcss_seek = (int (*)(dvdcss_handle, int, int)) dlsym(dvdcss_library, U_S "dvdcss_seek"); DVDcss_read = (int (*)(dvdcss_handle, void*, int, int)) dlsym(dvdcss_library, U_S "dvdcss_read"); DVDcss_error = (char* (*)(dvdcss_handle)) dlsym(dvdcss_library, U_S "dvdcss_error"); dvdcss_version = (char **)dlsym(dvdcss_library, U_S "dvdcss_interface_2"); if(dlsym(dvdcss_library, U_S "dvdcss_crack")) { if(verbose >= 0) { fprintf(stderr, "libdvdread: Old (pre-0.0.2) version of libdvdcss found.\n" "libdvdread: You should get the latest version from " "http://www.videolan.org/\n" ); } dlclose(dvdcss_library); dvdcss_library = NULL; } else if(!DVDcss_open || !DVDcss_close || !DVDcss_title || !DVDcss_seek || !DVDcss_read || !DVDcss_error || !dvdcss_version) { if(verbose >= 0) { fprintf(stderr, "libdvdread: Missing symbols in libdvdcss.so.2, " "this shouldn't happen !\n"); } dlclose(dvdcss_library); dvdcss_library = NULL; } } #endif /* HAVE_DVDCSS_DVDCSS_H */ dvdcss_library_init = 1; if(dvdcss_library) { /* char *psz_method = getenv( "DVDCSS_METHOD" ); char *psz_verbose = getenv( "DVDCSS_VERBOSE" ); fprintf(stderr, "DVDCSS_METHOD %s\n", psz_method); fprintf(stderr, "DVDCSS_VERBOSE %s\n", psz_verbose); */ if(verbose >= 1) { fprintf(stderr, "libdvdread: Using libdvdcss version %s for DVD access\n", *dvdcss_version); } /* libdvdcss wrapper functions */ dvdinput_open = css_open; dvdinput_close = css_close; dvdinput_seek = css_seek; dvdinput_title = css_title; dvdinput_read = css_read; dvdinput_error = css_error; return 1; } else { if(verbose >= 1) { fprintf(stderr, "libdvdread: Encrypted DVD support unavailable.\n"); } /* libdvdcss replacement functions */ dvdinput_open = file_open; dvdinput_close = file_close; dvdinput_seek = file_seek; dvdinput_title = file_title; dvdinput_read = file_read; dvdinput_error = file_error; return 0; } }
/* * Write the kerrnel command line to the sysfs based on configuration variables. If any * variable is not set then return an error. */ char * mpss_set_cmdline(struct mic_info *mic, struct mbridge *brlist, char *cmdline, char *ip) { char *verboseline = NULL; char *rootdev = NULL; char *console = NULL; char *cgroup = NULL; /* cmdline1 and cmdline2 must have the same size */ char cmdline1[2048]; char cmdline2[2048]; char pm[1024]; int err; size_t cmdlinesize = sizeof(cmdline1); verboseline = get_verbose(mic); snprintf(cmdline1, cmdlinesize, "%s", verboseline); if ((rootdev = get_rootdev(mic, brlist)) == NULL) { return "RootDevice parameter invalid"; } snprintf(cmdline2, cmdlinesize, "%s %s", cmdline1, rootdev); free(rootdev); if ((console = get_console(mic)) != NULL) { snprintf(cmdline1, cmdlinesize, "%s %s", cmdline2, console); free(console); } else { strncpy(cmdline1, cmdline2, cmdlinesize); } if ((cgroup = get_cgroup(mic)) != NULL) { snprintf(cmdline2, cmdlinesize, "%s %s", cmdline1, cgroup); free(cgroup); } else { strncpy(cmdline2, cmdline1, cmdlinesize); } if (mic->config.boot.extraCmdline != NULL) snprintf(cmdline1, cmdlinesize, "%s %s", cmdline2, mic->config.boot.extraCmdline); else strncpy(cmdline1, cmdline2, cmdlinesize); err = get_pm(mic, pm, sizeof(pm)); switch(err) { case 0: snprintf(cmdline2, cmdlinesize, "%s %s", cmdline1, pm); break; case ESRCH: strncpy(cmdline2, cmdline1, cmdlinesize); break; } if (ip != NULL) snprintf(cmdline1, cmdlinesize, "%s ip=%s", cmdline2, ip); else strncpy(cmdline1, cmdline2, cmdlinesize); if ((err = mpss_setsysfs(mic->name, "cmdline", cmdline1)) != 0) { return "Failed write command line to sysfs"; } if (cmdline != NULL) strncpy(cmdline, cmdline1, cmdlinesize); return NULL; }
void toggle_verbose (GtkWidget *box, GtkWidget *button) { /* This gets called from `gjackctl_setings_cb` that's in the `gjackctl_settings.c` module. */ GtkWidget *label; GtkWidget *event_box; gboolean verbose; gint state; GtkPassedData *data; label = gtk_label_new ("Verbose"); event_box = gtk_event_box_new (); state = label_normal_off (GTK_LABEL (label)); data = g_slice_new (GtkPassedData); data -> passed_label = label; verbose = get_verbose (); if (verbose == FALSE) { state = label_normal_off (GTK_LABEL (label)); data -> passed_state = state; } else { state = label_normal_on (GTK_LABEL (label)); data -> passed_state = state; } /* Initiate tooltip for `checkbox` in the if/else statement. It won't show when app first starts if we don't. */ if (state == GTK_LABEL_NORMAL_ON) { gtk_widget_set_tooltip_text (event_box, "Disable more output messages"); } else { gtk_widget_set_tooltip_text (event_box, "Enable more output messages"); } gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), TRUE); /* Pack `GtkGrid grid` which is declared in `gjackctl_settings.c` in the `gjackctl_settings_cb` function. */ gtk_container_add (GTK_CONTAINER (event_box), label); gtk_box_pack_start (GTK_BOX (box), event_box, FALSE, FALSE, 2); gtk_widget_set_halign (event_box, GTK_ALIGN_CENTER); gtk_widget_set_margin_start (event_box, 90); gtk_widget_add_events (event_box, GDK_BUTTON_PRESS_MASK); gtk_widget_add_events (event_box, GDK_BUTTON_RELEASE_MASK); gtk_widget_add_events (event_box, GDK_ENTER_NOTIFY_MASK); gtk_widget_add_events (event_box, GDK_LEAVE_NOTIFY_MASK); gtk_widget_add_events (event_box, GDK_PROPERTY_CHANGE_MASK); g_signal_connect (event_box, "button-release-event", G_CALLBACK (event_box_released_cb), data); g_signal_connect (event_box, "enter-notify-event", G_CALLBACK (enter_event_box_cb), label); g_signal_connect (event_box, "leave-notify-event", G_CALLBACK (leave_event_box_cb), data); g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), data); }