void setup(void) /***************************************************************************** * Input : * Output : * Function : ******************************************************************************/ { if(setup_lcm(LCM_IP)) { printf(" Failure in setup_lcm with this IP %s\n", LCM_IP); } else { printf(" LCM created with this IP %s\n", LCM_IP); } if(init_variables()) { } if(setup_threads()) // run threads { printf(" Threads UNSUCCESSFUL created\n"); } else { printf(" Threads succesful created\n"); } }
void start_quip_with_menu(int argc, char **argv, Menu *initial_menu_p ) { Query_Stack *qsp; assert( initial_menu_p != NULL ); set_progname(argv[0]); first_menu = initial_menu_p; //debug |= CTX_DEBUG_MASK; //debug |= GETBUF_DEBUG_MASK; qsp=init_first_query_stack(); // reads stdin? init_builtins(); init_variables(SINGLE_QSP_ARG); // specify dynamic variables declare_functions(SINGLE_QSP_ARG); //PUSH_MENU(quip); PUSH_MENU_PTR(initial_menu_p); set_args(QSP_ARG argc,argv); rcfile(qsp,argv[0]); // If we have commands to create a widget in the startup file, // we get an error, so don't call exec_quip until after the appDelegate // has started... } // end start_quip_with_menu
/** * charge le fichier de configuration et initialise les variabes. * * * * */ gboolean gsb_grisbi_init_app ( void ) { gboolean first_use = FALSE; gchar *string; #ifdef HAVE_PLUGINS gsb_plugins_scan_dir ( gsb_dirs_get_plugins_dir ( ) ); #endif /* create the icon of grisbi (set in the panel of gnome or other) */ string = g_build_filename ( gsb_dirs_get_pixmaps_dir ( ), "grisbi-logo.png", NULL ); if ( g_file_test ( string, G_FILE_TEST_EXISTS ) ) gtk_window_set_default_icon_from_file ( string, NULL ); g_free (string); /* initialisation of the variables */ gsb_color_initialise_couleurs_par_defaut ( ); init_variables (); register_import_formats (); /* firt use ? */ if ( ! gsb_file_config_load_config () ) first_use = TRUE; return first_use; }
void init (void) { /* Figure out the machine endianness. */ determine_endianness (); /* Must be first */ init_variables (); init_units (); set_fpu (); init_compile_options (); #ifdef DEBUG /* Check for special command lines. */ if (argc > 1 && strcmp (argv[1], "--help") == 0) show_variables (); /* if (argc > 1 && strcmp(argv[1], "--resume") == 0) resume(); */ #endif if (options.backtrace == 1) find_addr2line (); random_seed_i4 (NULL, NULL, NULL); }
t_list *completion_search_in_env(t_comp *comp) { t_env_list *env; t_list *match[2]; char *str; int ret; match[0] = init_variables(&env, &str, comp, &ret); while (env) { if (!(ret = ft_strncmp(str, env->name, ft_strlen(str))) && !match[0]) { if (!(match[0] = ft_lstnew(env->name, ft_strlen(env->name) + 1))) return (clear_matches_and_dir(comp, match[0], NULL)); match[1] = match[0]; } else if (!ret) { if (!(match[1]->next = ft_lstnew(env->name, ft_strlen(env->name) + 1))) return (clear_matches_and_dir(comp, match[0], NULL)); match[1] = match[1]->next; } env = env->next; (ret == 0) ? comp->nb_matches++ : 0; } return (match[0]); }
void new_video_window(char *filename) { #ifndef IPOD pz_error("No video support on the desktop."); #else /* IPOD */ if (full_hw_version==0) { full_hw_version = ipod_get_hw_version(); } outl(1, VAR_VIDEO_ON); outl(0, VAR_VIDEO_MODE); cop_wakeup(); init_variables(); video_status = VIDEO_CONTROL_MODE_STARTING; video_curPosition = 0; video_gc = pz_get_gc(1); GrSetGCUseBackground(video_gc, GR_FALSE); GrSetGCForeground(video_gc, GR_RGB(0,0,0)); //nes_window("Create win"); video_wid = pz_new_window(0, 0, screen_info.cols, screen_info.rows, video_do_draw, video_do_keystroke); GrSelectEvents(video_wid, GR_EVENT_MASK_KEY_DOWN| GR_EVENT_MASK_KEY_UP); GrMapWindow(video_wid); GrClearWindow(video_wid, GR_FALSE); //nes_window("Load"); video_status_message("Loading video..."); //nes_window("Play"); playVideo(filename); outl(0, VAR_VIDEO_ON); #endif }
const std::map< std::string, std::string >& atf::config::get_all(void) { if (m_variables.empty()) init_variables(); return m_variables; }
bool atf::config::has(const std::string& varname) { if (m_variables.empty()) init_variables(); return m_variables.find(varname) != m_variables.end(); }
static void setup(void) { env_set("VAR_A", "VAL_A"); env_set("VAR_B", "VAL_B"); env_set("VAR_C", "VAL_C"); init_variables(); }
const std::string& atf::config::get(const std::string& varname) { if (m_variables.empty()) init_variables(); PRE(has(varname)); return m_variables[varname]; }
int main(void) { type_t tau; init_type_table(&types, 0); init_variables(); init_types(); // pair(A) = (tuple A A) tau = pair_type(var[0], var[0]); test_macro("pair", 1, var, tau); // triple(B) = (tuple B B B) tau = triple_type(var[1], var[1], var[1]); test_macro("triple", 1, var+1, tau); // test(C, D) = bool test_macro("test", 2, var+2, base[0]); // fun(E, F) = (-> (tuple E E) F) tau = pair_type(var[4], var[4]); tau = function_type(&types, var[5], 1, &tau); test_macro("fun", 2, var+4, tau); // two constructors test_constructor("mk_type2", 2); test_constructor("mk_type3", 3); printf("\n====== TYPES ========\n"); print_type_table(stdout, &types); printf("\n===== MACROS ========\n"); print_type_macros(stdout, &types); printf("===\n\n"); // creation after remove // vector[G] = (-> int G) tau = int_type(&types); tau = function_type(&types, var[6], 1, &tau); test_macro("vector", 1, var+6, tau); // matrix[H] = (-> int int H) tau = int_type(&types); tau = binary_ftype(tau, tau, var[7]); test_macro("matrix", 1, var+7, tau); printf("\n====== TYPES ========\n"); print_type_table(stdout, &types); printf("\n===== MACROS ========\n"); print_type_macros(stdout, &types); printf("===\n\n"); delete_type_table(&types); return 0; }
int Init(void *_ctx) { int n; ctx = _ctx; moddebug("enter ts=%d\n",oesr_tstamp(ctx)); if (!mem_ok) { init_memory(); mem_ok = 1; } if (!log_ok) { mlog = NULL; if (USE_LOG) { if (init_log(ctx)) { return -1; } } log_ok = 1; } if (!check_ok) { if (check_configuration(ctx)) { return -1; } check_ok = 1; } if (init_variables(ctx)) { return -1; } if (init_counter(ctx)) { return -1; } moddebug("calling initialize, ts=%d\n",oesr_tstamp(ctx)); /* this is the module initialize function */ if (initialize()) { moddebug("error initializing module\n",oesr_tstamp(ctx)); return -1; } n = init_interfaces(ctx); if (n == -1) { return -1; } else if (n == 0) { return 0; } moddebug("exit ts=%d\n",oesr_tstamp(ctx)); return 1; }
int main(void) { signed int stat=0; init_buffers(); init_variables(); stat = init_signals_terminals_and_pipes(); if (stat != 0) printf("exiting-error in init_signals_terminals_and_pipes\n"); stat = run_matmult_p(); return stat; }
/** * Called by menu file -> new, * close the last file and open a new one * in fact just an assistant launcher, but need to check if the previous file is closed * * \param none * * \return FALSE * */ gboolean gsb_file_new ( void ) { /* continue only if closing the file is ok */ if ( !gsb_file_close () ) return FALSE; /* set up all the default variables */ init_variables (); gsb_assistant_file_run (FALSE, FALSE); return FALSE; }
void relache_slide_back (void) { if (event.button.x > 320 && event.button.x < 460 && event.button.y > 5 && event.button.y < 45) { positionBackP1.x = event.button.x; positionBackP1.y = event.button.y; if (positionBackP1.x - positionBackP0.x > 320) { init_variables(); affichage_accueil(); show = 0; touch = 0; } } }
/** * close the file * if no file loaded or no change, directly return TRUE * * \param * * \return FALSE if problem, TRUE if ok * */ gboolean gsb_file_close ( void ) { gint result; devel_debug (NULL); if ( !assert_account_loaded () ) return ( TRUE ); /* ask for saving */ result = gsb_file_dialog_save(); switch ( result ) { case GTK_RESPONSE_OK: /* try to save */ if ( !gsb_file_save_file (-1) ) return ( FALSE ); case GTK_RESPONSE_NO : /* remove the lock */ if ( !etat.fichier_deja_ouvert && gsb_data_account_get_accounts_amount () && nom_fichier_comptes ) gsb_file_util_modify_lock ( FALSE ); gsb_gui_init_general_vbox ( ); /* free all the variables */ init_variables (); gsb_account_property_clear_config ( ); gsb_main_set_grisbi_title ( -1 ); /* unsensitive the necessaries menus */ gsb_menu_set_menus_with_file_sensitive ( FALSE ); table_etat = NULL; return ( TRUE ); default : return FALSE; } }
void init_dictionary(cell *up) { /* reserve space for an array of tokens to the cfa of prim headers */ V(DP) += (MAXPRIM * sizeof(token_t)); #if 0 // Make a temporary vocabulary structure so header will have // a place to put its various links tokstore(CT_FROM_XT((xt_t)V(DP), up), &V(CONTEXT)); tokstore(CT_FROM_XT((xt_t)V(DP), up), &V(CURRENT)); linkcomma(DOVOC); linkcomma(CT_FROM_XT(V(TORIGIN), up)); linkcomma(CT_FROM_XT(V(TORIGIN), up)); /* Make the initial dictionary entry */ header("forth", sizeof("forth")-1); #else place_name("forth", sizeof("forth")-1, CT_FROM_XT((xt_t)V(TORIGIN), up), up); #endif // Install the new vocabulary in the search order and the vocabulary list tokstore(CT_FROM_XT((xt_t)V(DP), up), (xt_t)&V(CONTEXT)); tokstore(CT_FROM_XT((xt_t)V(DP), up), (xt_t)&V(CURRENT)); tokstore(CT_FROM_XT((xt_t)V(DP), up), (xt_t)&V(VOC_LINK)); compile((token_t)DOVOC); // Code field #ifdef RELOCATE set_relocation_bit(V(DP)); #endif #if 0 linkcomma(T(LASTP)); // last-word field #else unumcomma(0); // Forth voc threads are first thing in user area *(xt_t)(&up[0]) = T(LASTP); #endif linkcomma(CT_FROM_XT((xt_t)V(TORIGIN), up)); // voc-link field init_variables(sizeof(cell), up); // arg is first avail user number init_entries(up); }
// Initialize everything static void init() { int error; // Open files error = create_reader(); if (error != 0) { fprintf(stderr, "%s: %s\n", get_input(), strerror(errno)); exit(1); } error = create_writer(); if (error != 0) { fprintf(stderr, "%s: %s\n", get_output(), strerror(errno)); exit(2); } // Basic Huffman tree init_variables(); }
void init_commands(void) { if(cmds_conf.inner != NULL) { init_cmds(1, &cmds_conf); return; } /* We get here when init_commands() is called the first time. */ init_cmds(1, &cmds_conf); add_builtin_commands((const cmd_add_t *)&cmds_list, cmds_list_size); /* Initialize modules used by this one. */ init_bracket_notation(); init_variables(); vle_aucmd_set_expand_hook(&pattern_expand_hook); }
// // Initialize terrain // void t_init() { // Initialize terrain parameters t_terrain_sta = 0; t_terrain_end = 0; terrain_left = -T_TERRAIN_START_WIDTH*0.5; terrain_right = T_TERRAIN_START_WIDTH*0.5; // Initialize first previous segment (not in buffer) for(int i=0; i<T_TERRAIN_DOT_N; i++) { t_terrain[0].vertices[i].pos = vec3(terrain_left + i*(terrain_right-terrain_left)/(T_TERRAIN_DOT_N-1), 0, 0); t_terrain[0].vertices[i].n = vec3(0.0, 1.0, 0.0); } init_variables(); // Init terrain while(t_new_segment()); }
SMC::SMC () { if (!initialized) { init_runtime(); init_stencil(); init_chemistry(); init_variables(); initialized = true; } build_multifabs(); init_from_scratch(); wt_fb1 = wt_fb2 = wt_chem1 = wt_chem2 = wt_hypdiff = 0.0; }
/** * come here to finish to create the new file * at this time, categories and currencies must created * this part will just launch the assistant to create a new account * a finish the initialisation to lauch grisbi * * \param * * \return FALSE * */ gboolean gsb_file_new_finish ( void ) { /* create the first account */ if (! gsb_assistant_account_run ()) { init_variables (); return FALSE; } /* the the name in the last opened files */ gsb_file_append_name_to_opened_list ( nom_fichier_comptes ); /* init the gui */ gsb_file_new_gui (); mise_a_jour_accueil ( TRUE ); gsb_gui_navigation_set_selection ( GSB_HOME_PAGE, -1, NULL ); gsb_file_set_modified ( TRUE ); return FALSE; }
init (void) { /* Figure out the machine endianness. */ determine_endianness (); /* Must be first */ init_variables (); init_units (); #ifdef DEBUG /* Check for special command lines. */ if (argc > 1 && strcmp (argv[1], "--help") == 0) show_variables (); /* if (argc > 1 && strcmp(argv[1], "--resume") == 0) resume(); */ #endif memory_init (); random_seed(NULL,NULL,NULL); }
/*---------------------------------------------------------------------------*/ int main (int argc, char *argv[]) { init_variables(); if (InitCVIRTE (0, argv, 0) == 0) return -1; DisableBreakOnLibraryErrors (); setup_oscillo(); setup_SRS(); start_shaper(); generate_xarray (); if ((Main_pnl_handle = LoadPanel (0, "ERG.uir", ERG_panel)) < 0) return -1; mask_folder(Main_pnl_handle,99,EVENT_COMMIT,0,0,0); PopulateList(); strcpy (mask_filename, "flat"); display_masks(); DisplayPanel (Main_pnl_handle); RunUserInterface (); DiscardPanel (Main_pnl_handle); stop_shaper(); return 0; }
int main(int argc, char *argv[], char *envp[]) { char *channel; debug_init(); srand((unsigned)time(NULL)); time(&start_time); time(&idle_time); time(&now); #ifdef WINNT fprintf(stdout, "%s %s\r\n", nap_version, internal_version); fprintf(stdout, "%s\r\n", main_version); #else fprintf(stdout, "%s %s\n", nap_version, internal_version); fprintf(stdout, "%s\n", main_version); #endif channel = parse_args(argv, argc, envp); FD_ZERO(&readables); FD_ZERO(&writables); if (term_init(NULL)) _exit(1); /* my_signal(SIGQUIT, SIG_IGN, 0);*/ my_signal(SIGHUP, irc_exit_old, 0); my_signal(SIGTERM, irc_exit_old, 0); my_signal(SIGPIPE, SIG_IGN, 0); my_signal(SIGINT, cntl_c, 0); my_signal(SIGALRM, nothing, 0); my_signal(SIGCHLD, child_reap, 0); my_signal(SIGCONT, term_cont, 0); my_signal(SIGWINCH, sig_refresh_screen, 0); my_signal(SIGUSR1, sigusr1, 0); if (!init_screen()) { create_new_screen(); new_window(main_screen); } init_keys(); init_keys2(); init_variables(); #ifdef WANT_THREAD init_share_mutexes(); #ifdef WANT_NSLOOKUP start_dns(); #endif #ifdef WANT_MP3PLAYER start_mp3(); #endif #ifdef GTK start_tgtk(); #endif #endif build_status(current_window, NULL, 0); update_input(UPDATE_ALL); #ifndef WINNT charset_ibmpc(); #endif load_scripts(); read_unfinished_list(); if (auto_connect) { int serv = 0; reload_save(NULL, NULL, NULL, NULL, 0); if (starting_server != -1) serv = starting_server; connect_to_server_by_refnum(serv, -1, create); current_window->server = serv; xterm_settitle(); } else { if (do_get_napigator) get_napigator(); display_server_list(); } set_input_prompt(current_window, get_string_var(INPUT_PROMPT_VAR), 0); for (;;) io("main"); #ifdef GUI1 gui_exit(); #else nappanic("get_line() returned"); #endif return (-((int)0xdead)); }
//MAIN DEL PROGRAMA int main(void) { //Config uC Config_uC(); //Config Peripherals Config_Peripherals(); //Inicializa las Variables init_variables(); //Habilita las interrupciones __enable_interrupt(); for(;;) { //Activa el modo bajo consumo __low_power_mode_0(); //Si hay alguna tarea activa while(task.total != OFF) { /********************************/ //si task.f0 activa if(task.f0 == ON) { task.f0 = OFF; //Limpia la flag //si hay pausa pon el contador de secuencia a 0 //comienza una nueva secuencia if(last_pause != 0) { c_sequence = 0; } }//end if(task.f0 == ON) /********************************/ //si task.f1 activada //Si hemos soltado el boton activa esta tarea //Añade el simbolo correspondiente a la secuencia if(task.f1 == ON) { task.f1 = OFF; //Limpia el flag if(symbol == DASH) { sequence[c_sequence] = '-'; } else { sequence[c_sequence] = '.'; } c_sequence++; //+1 para el siguiente simbolo }//end if(task.f1 == ON) /********************************/ //LED1 ON if(task.f2 == ON) { task.f2 = OFF; //limpia la flag P1OUT_bit.P0 = LED_ON; //led1 on //ACTIVATE TIMER TA1CTL_bit.TACLR = ON; //Inicia la cuenta TA1CTL_bit.MC0 = ON; //Empieza la cuenta TA1CCTL0_bit.CCIFG = OFF; //Limpia la flag de interrupcion Timer1 TA1CCTL0_bit.CCIE = ON; //Habilita la interrupcion Timer1 }//end if(task.f2 == ON) /********************************/ //LED2 ON if(task.f3 == ON) { task.f3 = OFF; //Limpia la Flag P1OUT_bit.P6 = LED_ON; //Enciende Led2 //ACTIVATE TIMER TA1CTL_bit.TACLR = ON; //Inicia la cuenta TA1CTL_bit.MC0 = ON; //Empieza la cuenta TA1CCTL0_bit.CCIFG = OFF; //Limpia la flag TA1CCTL0_bit.CCIE = ON; //Habilita la interrupcion Timer1 }//end if(task.f3 == ON) }//end while(task.total != OFF) }//end for(;;) }//end main(void)
int main(int argc, char *argv[]) { /* main * The main LEAP program - This performs the display of the * title, and processes the command line. Clean termination * also should occur here. Everywhere else termination is * "unclean", and should return an error status. Define * error status' in the dtypes.h file */ #ifdef FULL_DEBUG /* Test vars */ char source[50],result[50],*sptr; #endif boolean tdebug=FALSE,ttiming=FALSE,ttimelog=FALSE,tlong=FALSE; boolean tquiet=FALSE,ttrace=FALSE,tpad=FALSE,tpjoin=FALSE; time_t tp; char *s; char *argptr; /******************************** * Startup - Firstly set up the * signal handlers ********************************/ /* Signal Interrupt from the keyboard - the daemon should handle it */ signal(SIGINT,&signal_handler); /* MSDOS/Windows does not know SIGQUIT/SIGHUP, whereas * these are important in Unix */ #ifndef __MSDOS__ /* Signal Quit from the keyboard - Ignore it */ signal(SIGQUIT,SIG_IGN); /* Signal Hang up - Handle it */ signal(SIGHUP,&signal_handler); #else #endif define_handle(&default_handler,&errorHandler); raise_message(EVENT, "%s","Event Handler initialised."); define_handle(&default_quiethandler,&messageHandler); raise_message(EVENT,"%s","Message Handler initialised."); /* Signal Terminate - Handle it */ signal(SIGTERM,&signal_handler); /* Perform some configuration... */ build_base_dir(LEAP_DEFAULT_DIR); /* Set the random seed to the time in secs since 01.01.1970 * should be random enough! */ srand(time(NULL)); s=getenv(LEAP_ENV_DIR); strcpy(dbtoopen,""); strcpy(activityfile,""); strcpy(tempdir,""); ACTIVITY_FILE=NULL; if (s!=NULL) { leap_fprintf(stdout,"Using environment variable %s for path (%s).\n",LEAP_ENV_DIR,s); build_base_dir(s); } /* Process the command line Stop if we run out of arguments or we get an argument without a dash */ /* NB. This is based on O'Reilly & Associates "Practical C Programming", by Steve Oualline, 2nd Ed. (pg 178) */ while ((argc > 1) && (argv[1][0] == '-')) { /* * argv[1][1] is the actual option character */ if ((argv[1][0]==ARGUMENT_PREFIX) && (argv[1][1]==ARGUMENT_PREFIX)) { argptr=&argv[1][2]; } else { argptr=&argv[1][1]; } switch (*argptr) { case 'a': case 'A': if ((strcmp(argptr,"activity-file")==0)||(strcmp(argptr,"activity")==0)||(strlen(argptr)==1)) { if (specify(activityfile,argv[2],FILE_PATH_SIZE)){ argv++; argc--; } else { leap_fprintf(stderr,"No file specified. Using %s\n",LEAP_ACTIVITY_FILE); strncpy(activityfile,LEAP_ACTIVITY_FILE,FILE_PATH_SIZE); } ACTIVITY_FILE=fopen(activityfile,"a"); if (ACTIVITY_FILE==NULL) { leap_fprintf(stderr,"Unable to open activity file for appending.\n"); } else { tp=time(NULL); fprintf(ACTIVITY_FILE,"###\n# Activity file STARTED at: %s###\n",ctime(&tp)); leap_printf("Activity file: %s\n",activityfile); } } break; case 'b': case 'B': if (specify(dbtoopen,argv[2],DATABASE_NAME_SIZE)){ argv++; argc--; } else { raise_message(MESSAGE,"No database specified on command line. %s will be used.",DEFAULT_DB); } break; case 'd': case 'D': if ((strcmp(argptr,"dir")==0)||(strcmp(argptr,"directory")==0)||(strlen(argptr)==1)) { if (argv[2]) { build_base_dir(argv[2]); /* Increment the counts... */ argv++; argc--; } else { leap_fprintf(stderr,"ERROR: No directory specified after directory flag.\n"); exit(1); } } else if (strcmp(argptr,"database")==0) { if (specify(dbtoopen,argv[2],DATABASE_NAME_SIZE)){ argv++; argc--; } } else if (strcmp(argptr,"debug")==0) { /* The user wants debug information */ leap_printf("Debug messages enabled\n"); tdebug=TRUE; } break; case 'e': case 'E': if (strlen(argptr)==1) { /* The user wants debug information */ leap_printf("Debug messages enabled\n"); tdebug=TRUE; } else if ((strcmp(argptr,"events")==0)||(strcmp(argptr,"event")==0)) { /* User wants event reports */ define_handle(&default_quiethandler,&eventHandler); raise_message(EVENT,"%s","Event Handler initialised."); } break; case 'h': case '?': case 'H': if ((strcmp(argptr,"help")==0)||(strlen(argptr)==1)) { /* The user wants some help... */ print_help(); /* Exit without an error */ exit(0); /* Lint-ified - The break is not reached */ /* break; */ } case 'i': case 'I': /* The user wants timing information */ leap_printf("Timing information enabled\n"); ttiming=TRUE; break; case 'l': case 'L': if ((strcmp(argptr,"time-logging")==0)||(strlen(argptr)==1)) { /* Do not fetch the system time in log file */ leap_printf("Time logging disabled\n"); ttimelog=FALSE; } else if ((strcmp(argptr,"long-commands")==0)||(strcmp(argptr,"long")==0)){ leap_printf("Long commands enabled\n"); tlong=TRUE; } break; case 'n': case 'N': /* Display warranty information */ do_warranty(); exit(0); /* Lint-ified - The break is not reached */ /* break; */ case 'o': case 'O': leap_printf("Long commands enabled\n"); tlong=TRUE; break; case 'p': case 'P': if ((strcmp(argptr,"padding")==0)||(strlen(argptr)==1)) { leap_printf("Relation Name Padding enabled\n"); tpad=TRUE; } else if ((strcmp(argptr,"product-join")==0)||(strcmp(argptr,"pjoin")==0)) { leap_printf("Product performed in no-condition join\n"); tpjoin=TRUE; } break; case 'q': case 'Q': if ((strcmp(argptr,"quiet")==0)||(strlen(argptr)==1)) { tquiet=TRUE; BEEP=' '; /* Shutdown the message handler */ define_handle(NULL,&messageHandler); } break; case 'r': case 'R': if ((strcmp(argptr,"regression")==0)||(strlen(argptr)==1)) { /* What!? This is to disable outputting * items that might cause regression tests * to fail for no good reason, ie. * temporary relation names which are random, * and will differ between runs. */ status_regression=TRUE; leap_printf("Regression test mode on\n"); } break; case 's': case 'S': if ((strcmp(argptr,"status")==0)||(strlen(argptr)==1)) { /* The user wants status messages to be displayed */ leap_printf("Status messages enabled\n"); status=TRUE; } break; case 't': case 'T': if ((strcmp(argptr,"time")==0)||(strcmp(argptr,"timing")==0)) { /* The user wants timing information */ leap_printf("Timing information enabled\n"); ttiming=TRUE; } else if ((strlen(argptr)==1)||(strcmp(argptr,"trace")==0)||(strcmp(argptr,"tracing")==0)) { /* The user wants tracing information */ leap_printf("Tracing information enabled\n"); ttrace=TRUE; } break; case 'v': case 'V': if ((strcmp(argptr,"version")==0)||(strlen(argptr)==1)) { /* Print BRIEF version information */ print_header(TRUE); exit(0); } break; case 'w': case 'W': if ((strcmp(argptr,"warranty")==0)||(strlen(argptr)==1)) { do_warranty(); exit(0); } break; case 'x': case 'X': if (argv[2]) { strncpy(tempdir,argv[2],FILE_PATH_SIZE); /* Increment the counts... */ argv++; argc--; } else { leap_fprintf(stderr,"ERROR: No directory specified after temporary directory flag.\n"); exit(1); } break; default: raise_error(ERROR_COMMAND_LINE,NONFATAL,argptr); } /* Move the argument list up one and the count down one */ argv++; argc--; } raise_message(EVENT,"%s","Command line processed."); /* First things first, report (verbosely) what we are. */ if ((status_regression!=TRUE) && (tquiet!=TRUE)) print_header(FALSE); if ( (status) && (tquiet!=TRUE) ) { sprintf(temp_80_chars,"LEAP Base directory set to: %s",LEAP_BASE_DIR); leap_printf(temp_80_chars); } /* Call any initialisation routines... */ util_init(); /* This has to be done after the path is read, so that * the variable config file is located. */ if (init_variables()!=RETURN_SUCCESS) { raise_message(MESSAGE,"Directory specified [%s] not valid. Trying [%s]",LEAP_BASE_DIR,LEAP_TRY_DIR); build_base_dir(LEAP_TRY_DIR); if (init_variables()!=RETURN_SUCCESS) { raise_message(MESSAGE,"[%s] is also not valid - Problems are likely",LEAP_TRY_DIR); } else { raise_message(MESSAGE,"Variables are now set."); } } if (tdebug==TRUE) set_variable(STATUS_DEBUG,STATUS_SETTING_ON); if (ttiming==TRUE) set_variable(STATUS_TIMING,STATUS_SETTING_ON); if (ttimelog==TRUE) set_variable(STATUS_TIMELOG,STATUS_SETTING_ON); if (tlong==FALSE) set_variable(STATUS_LONGLINE,STATUS_SETTING_OFF); if (tquiet==TRUE) set_variable(STATUS_QUIET,STATUS_SETTING_ON); if (ttrace==TRUE) set_variable(STATUS_TRACE,STATUS_SETTING_ON); if (tpad==TRUE) set_variable(STATUS_PADDING,STATUS_SETTING_ON); if (tpjoin==TRUE) set_variable(STATUS_PRODUCTJOIN,STATUS_SETTING_ON); /* Display some information */ if (status_quiet!=TRUE) { raise_message(MESSAGE,"LEAP is starting..."); } #ifdef DEBUG status_debug=TRUE; leap_fprintf(stderr,"DEBUG: LEAP debug mode forced on\n"); #endif /* Do the main leap operation */ (void) do_daemon(); print_shutdown(); /* Close the various files opened earlier */ util_close(); if (status_quiet!=TRUE) { /* Inform the user of a clean termination */ raise_message(MESSAGE,"LEAP Terminated successfully!"); } /* Return success. Elsewhere, non-zero should be returned */ return(0); }
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), m_varEqBands( pIntf ), m_pVout( NULL ), m_pAout( NULL ), m_bEqualizer_started( false ) { // Create and register VLC variables VarManager *pVarManager = VarManager::instance( getIntf() ); #define REGISTER_VAR( var, type, name ) \ var = VariablePtr( new type( getIntf() ) ); \ pVarManager->registerVar( var, name ); REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" ) REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" ) REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" ) REGISTER_VAR( m_cPlaytree, Playtree, "playtree" ) pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(), "playtree.slider" ); pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" ); pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" ); REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" ) REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" ) REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" ) /* Input variables */ pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" ); REGISTER_VAR( m_cVarTime, StreamTime, "time" ) REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" ) REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" ) REGISTER_VAR( m_cVarRecordable, VarBoolImpl, "vlc.canRecord" ) REGISTER_VAR( m_cVarRecording, VarBoolImpl, "vlc.isRecording" ) /* Vout variables */ REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" ) REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" ) /* Aout variables */ REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" ) REGISTER_VAR( m_cVarVolume, Volume, "volume" ) REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" ) REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" ) REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" ) #undef REGISTER_VAR m_cVarSpeed = VariablePtr( new VarText( getIntf(), false ) ); pVarManager->registerVar( m_cVarSpeed, "speed" ); SET_TEXT( m_cVarSpeed, UString( getIntf(), "1") ); m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) ); pVarManager->registerVar( m_cVarStreamName, "streamName" ); m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) ); pVarManager->registerVar( m_cVarStreamURI, "streamURI" ); m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) ); pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" ); m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) ); pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" ); m_cVarStreamArt = VariablePtr( new VarString( getIntf() ) ); pVarManager->registerVar( m_cVarStreamArt, "streamArt" ); // Register the equalizer bands for( int i = 0; i < EqualizerBands::kNbBands; i++) { stringstream ss; ss << "equalizer.band(" << i << ")"; pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() ); } // XXX WARNING XXX // The object variable callbacks are called from other VLC threads, // so they must put commands in the queue and NOT do anything else // (X11 calls are not reentrant) #define ADD_CALLBACK( p_object, var ) \ var_AddCallback( p_object, var, onGenericCallback, this ); ADD_CALLBACK( pIntf->p_sys->p_playlist, "volume" ) ADD_CALLBACK( pIntf->p_libvlc, "intf-toggle-fscontrol" ) ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" ) ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" ) ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" ) ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" ) #undef ADD_CALLBACK // Called when a playlist item is added var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append", onItemAppend, this ); // Called when a playlist item is deleted // TODO: properly handle item-deleted var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted", onItemDelete, this ); // Called when the current input changes var_AddCallback( pIntf->p_sys->p_playlist, "input-current", onInputNew, this ); // Called when a playlist item changed var_AddCallback( pIntf->p_sys->p_playlist, "item-change", onItemChange, this ); // Called when we have an interaction dialog to display var_Create( pIntf, "interaction", VLC_VAR_ADDRESS ); var_AddCallback( pIntf, "interaction", onInteraction, this ); // initialize variables refering to liblvc and playlist objects init_variables(); }
/**************************************************************************** * Public Functions ****************************************************************************/ int mqtt_client_sub_task(void *arg) { int result = -1; int ret = 0; int argc; char **argv; argc = ((struct mqtt_sub_input *)arg)->argc; argv = ((struct mqtt_sub_input *)arg)->argv; if (argc == 1) { print_usage(); return 0; } /* set the seed of a new sequence of random values */ mqtt_set_srand(); /* check options and set variables */ init_variables(); ret = process_options(argc, argv); if (ret != 0) { if (ret == 2) { print_usage(); result = 0; } goto done; } /* check and do options when a client is running */ ret = check_option_on_client_running(); if (ret == CHECK_OPTION_RESULT_CHECKED_OK) { result = 0; goto done; } else if (ret == CHECK_OPTION_RESULT_CHECKED_ERROR) { goto done; } /* make mqtt subscriber client config */ if (make_client_config() != 0) { goto done; } /* create mqtt subscriber client */ if (g_debug) { printf("initialize MQTT client context.\n"); } g_mqtt_client_handle = mqtt_init_client(&g_mqtt_client_config); if (g_mqtt_client_handle == NULL) { fprintf(stderr, "Error: mqtt_init_client() failed.\n"); clean_client_config(); goto done; } /* connect to a mqtt broker */ if (g_debug) { printf("connect to a MQTT broker (%s : %d).\n", g_host_addr, g_port); } if (mqtt_connect(g_mqtt_client_handle, g_host_addr, g_port, g_keepalive) != 0) { fprintf(stderr, "Error: mqtt_connect() failed.\n"); if (mqtt_deinit_client(g_mqtt_client_handle) != 0) { fprintf(stderr, "Error: mqtt_deinit_client() failed.\n"); } else { g_mqtt_client_handle = NULL; } clean_client_config(); goto done; } if (g_debug) { printf("MQTT subscriber has started successfully.\n"); } /* result is success */ result = 0; done: deinit_variables(); return result; }
int handle_options(int *argc, char ***argv, const struct my_option *longopts, my_bool (*get_one_option)(int, const struct my_option *, char *)) { uint opt_found, argvpos= 0, length, i; my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used, option_is_loose; char *progname= *(*argv), **pos, **pos_end, *optend, *prev_found; const struct my_option *optp; int error; LINT_INIT(opt_found); (*argc)--; /* Skip the program name */ (*argv)++; /* --- || ---- */ init_variables(longopts); for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++) { char *cur_arg= *pos; if (cur_arg[0] == '-' && cur_arg[1] && !end_of_options) /* must be opt */ { char *argument= 0; must_be_var= 0; set_maximum_value= 0; special_used= 0; option_is_loose= 0; cur_arg++; /* skip '-' */ if (*cur_arg == '-' || *cur_arg == 'O') /* check for long option, */ { /* --set-variable, or -O */ if (*cur_arg == 'O') { must_be_var= 1; if (!(*++cur_arg)) /* If not -Ovar=# */ { /* the argument must be in next argv */ if (!*++pos) { if (my_getopt_print_errors) fprintf(stderr, "%s: Option '-O' requires an argument\n", progname); return EXIT_ARGUMENT_REQUIRED; } cur_arg= *pos; (*argc)--; } } else if (!getopt_compare_strings(cur_arg, "-set-variable", 13)) { must_be_var= 1; if (cur_arg[13] == '=') { cur_arg+= 14; if (!*cur_arg) { if (my_getopt_print_errors) fprintf(stderr, "%s: Option '--set-variable' requires an argument\n", progname); return EXIT_ARGUMENT_REQUIRED; } } else if (cur_arg[14]) /* garbage, or another option. break out */ must_be_var= 0; else { /* the argument must be in next argv */ if (!*++pos) { if (my_getopt_print_errors) fprintf(stderr, "%s: Option '--set-variable' requires an argument\n", progname); return EXIT_ARGUMENT_REQUIRED; } cur_arg= *pos; (*argc)--; } } else if (!must_be_var) { if (!*++cur_arg) /* skip the double dash */ { /* '--' means end of options, look no further */ end_of_options= 1; (*argc)--; continue; } } optend= strcend(cur_arg, '='); length= optend - cur_arg; if (*optend == '=') optend++; else optend=0; /* Find first the right option. Return error in case of an ambiguous, or unknown option */ optp= longopts; if (!(opt_found= findopt(cur_arg, length, &optp, &prev_found))) { /* Didn't find any matching option. Let's see if someone called option with a special option prefix */ if (!must_be_var) { if (optend) must_be_var= 1; /* option is followed by an argument */ for (i= 0; special_opt_prefix[i]; i++) { if (!getopt_compare_strings(special_opt_prefix[i], cur_arg, special_opt_prefix_lengths[i]) && cur_arg[special_opt_prefix_lengths[i]] == '-') { /* We were called with a special prefix, we can reuse opt_found */ special_used= 1; cur_arg+= (special_opt_prefix_lengths[i] + 1); if (i == OPT_LOOSE) option_is_loose= 1; if ((opt_found= findopt(cur_arg, length - (special_opt_prefix_lengths[i] + 1), &optp, &prev_found))) { if (opt_found > 1) { if (my_getopt_print_errors) fprintf(stderr, "%s: ambiguous option '--%s-%s' (--%s-%s)\n", progname, special_opt_prefix[i], cur_arg, special_opt_prefix[i], prev_found); return EXIT_AMBIGUOUS_OPTION; } switch (i) { case OPT_SKIP: case OPT_DISABLE: /* fall through */ /* double negation is actually enable again, for example: --skip-option=0 -> option = TRUE */ optend= (optend && *optend == '0' && !(*(optend + 1))) ? (char*) "1" : disabled_my_option; break; case OPT_ENABLE: optend= (optend && *optend == '0' && !(*(optend + 1))) ? disabled_my_option : (char*) "1"; break; case OPT_MAXIMUM: set_maximum_value= 1; must_be_var= 1; break; } break; /* break from the inner loop, main loop continues */ } } } } if (!opt_found) { if (must_be_var) { if (my_getopt_print_errors) fprintf(stderr, "%s: %s: unknown variable '%s'\n", progname, option_is_loose ? "WARNING" : "ERROR", cur_arg); if (!option_is_loose) return EXIT_UNKNOWN_VARIABLE; } else { if (my_getopt_print_errors) fprintf(stderr, "%s: %s: unknown option '--%s'\n", progname, option_is_loose ? "WARNING" : "ERROR", cur_arg); if (!option_is_loose) return EXIT_UNKNOWN_OPTION; } if (option_is_loose) { (*argc)--; continue; } } } if (opt_found > 1) { if (must_be_var) { if (my_getopt_print_errors) fprintf(stderr, "%s: variable prefix '%s' is not unique\n", progname, cur_arg); return EXIT_VAR_PREFIX_NOT_UNIQUE; } else { if (my_getopt_print_errors) fprintf(stderr, "%s: ambiguous option '--%s' (%s, %s)\n", progname, cur_arg, prev_found, optp->name); return EXIT_AMBIGUOUS_OPTION; } } if (must_be_var && optp->var_type == GET_NO_ARG) { if (my_getopt_print_errors) fprintf(stderr, "%s: option '%s' cannot take an argument\n", progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } if (optp->arg_type == NO_ARG) { if (optend && optp->var_type != GET_BOOL) { if (my_getopt_print_errors) fprintf(stderr, "%s: option '--%s' cannot take an argument\n", progname, optp->name); return EXIT_NO_ARGUMENT_ALLOWED; } if (optp->var_type == GET_BOOL) { /* Set bool to 1 if no argument or if the user has used --enable-'option-name'. *optend was set to '0' if one used --disable-option */ *((my_bool*) optp->value)= (my_bool) (!optend || *optend == '1'); (*argc)--; get_one_option(optp->id, optp, argument); continue; } argument= optend; } else if (optp->arg_type == OPT_ARG && optp->var_type == GET_BOOL) { if (optend == disabled_my_option) *((my_bool*) optp->value)= (my_bool) 0; else { if (!optend) /* No argument -> enable option */ *((my_bool*) optp->value)= (my_bool) 1; else /* If argument differs from 0, enable option, else disable */ *((my_bool*) optp->value)= (my_bool) atoi(optend) != 0; } (*argc)--; continue; } else if (optp->arg_type == REQUIRED_ARG && !optend) { /* Check if there are more arguments after this one */ if (!*++pos) { if (my_getopt_print_errors) fprintf(stderr, "%s: option '--%s' requires an argument\n", progname, optp->name); return EXIT_ARGUMENT_REQUIRED; } argument= *pos; (*argc)--; } else argument= optend; } else /* must be short option */ { for (optend= cur_arg; *optend; optend++) { opt_found= 0; for (optp= longopts; optp->id; optp++) { if (optp->id == (int) (uchar) *optend) { /* Option recognized. Find next what to do with it */ opt_found= 1; if (optp->var_type == GET_BOOL && optp->arg_type == NO_ARG) { *((my_bool*) optp->value)= (my_bool) 1; get_one_option(optp->id, optp, argument); continue; } else if (optp->arg_type == REQUIRED_ARG || optp->arg_type == OPT_ARG) { if (*(optend + 1)) { /* The rest of the option is option argument */ argument= optend + 1; /* This is in effect a jump out of the outer loop */ optend= (char*) " "; } else if (optp->arg_type == REQUIRED_ARG) { /* Check if there are more arguments after this one */ if (!*++pos) { if (my_getopt_print_errors) fprintf(stderr, "%s: option '-%c' requires an argument\n", progname, optp->id); return EXIT_ARGUMENT_REQUIRED; } argument= *pos; (*argc)--; /* the other loop will break, because *optend + 1 == 0 */ } } if ((error= setval(optp, argument, set_maximum_value))) { fprintf(stderr, "%s: Error while setting value '%s' to '%s'\n", progname, argument, optp->name); return error; } get_one_option(optp->id, optp, argument); break; } } if (!opt_found) { if (my_getopt_print_errors) fprintf(stderr, "%s: unknown option '-%c'\n", progname, *optend); return EXIT_UNKNOWN_OPTION; } } (*argc)--; /* option handled (short), decrease argument count */ continue; } if ((error= setval(optp, argument, set_maximum_value))) { fprintf(stderr, "%s: Error while setting value '%s' to '%s'\n", progname, argument, optp->name); return error; } get_one_option(optp->id, optp, argument); (*argc)--; /* option handled (short�or�long), decrease argument count */ } else /* non-option found */ (*argv)[argvpos++]= cur_arg; } /* Destroy the first, already handled option, so that programs that look for arguments in 'argv', without checking 'argc', know when to stop. Items in argv, before the destroyed one, are all non-option -arguments to the program, yet to be (possibly) handled. */ (*argv)[argvpos]= 0; return 0; }