bool defdeps(struct symbol *sym) { if (!sym->name || strlen(sym->name) == 0) return true; if (sym->searched) return sym->depends; sym->searched = true; if (is_default(sym)) { sym->depends = true; return true; } if (!sym->dir_dep.expr && !sym->rev_dep.expr) { sym->depends = false; return false; } sym->depends = true; if (sym->dir_dep.expr) sym->depends = sym->depends && defdeps_expr(sym->dir_dep.expr); if (sym->rev_dep.expr) sym->depends = sym->depends && defdeps_expr(sym->rev_dep.expr); return sym->depends; }
void isis_redist_delete(int type, struct prefix *p) { int family = p->family; struct route_table *ei_table = get_ext_info(isis, family); struct route_node *ei_node; struct listnode *node; struct isis_area *area; int level; struct isis_redist *redist; char debug_buf[BUFSIZ]; prefix2str(p, debug_buf, sizeof(debug_buf)); zlog_debug("%s: Removing route %s from %s.", __func__, debug_buf, zebra_route_string(type)); if (is_default(p)) { /* Don't remove default route but add synthetic route for use * by "default-information originate always". Areas without the * "always" setting will ignore routes with origin DEFAULT_ROUTE. */ isis_redist_add(DEFAULT_ROUTE, p, 254, MAX_WIDE_PATH_METRIC); return; } if (!ei_table) { zlog_warn("%s: External information table not initialized.", __func__); return; } ei_node = route_node_lookup(ei_table, p); if (!ei_node || !ei_node->info) { char buf[BUFSIZ]; prefix2str(p, buf, sizeof(buf)); zlog_warn("%s: Got a delete for %s route %s, but that route" " was never added.", __func__, zebra_route_string(type), buf); if (ei_node) route_unlock_node(ei_node); return; } route_unlock_node(ei_node); for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) for (level = 1; level < ISIS_LEVELS; level++) { redist = get_redist_settings(area, family, type, level); if (!redist->redist) continue; isis_redist_uninstall(area, level, p); } XFREE(MTYPE_ISIS, ei_node->info); route_unlock_node(ei_node); }
void data_type<T>::set_context_default( const string& name, const matrix_separators* p_matsep ) { istrstream is(name.c_str()); if (p_matsep==NULL) p_matsep = &g_matrix_ddl_separators; bool restore = !is_default(); ix_type old_ix = m_ix; // Index auf alten Wert zwischenspeichern if (mp_context->get_default_ix()==g_illegal_ix) { // noch kein Context-spezifischer Default-Wert, also glob. Default-Wert allocate(); // neuen Platz bekommen read(is,p_matsep); // Default-Wert auslesen mp_context->set_default_ix(m_ix); // und im Context speichern } else { // bereits Context-spez. Default-Wert bekannt, alten Wert ueberschreiben load(mp_context->get_default_ix()); // alten Default-Wert laden // Das Einlesen ueber read(is) ueberschreibt den Default-Wert // nicht, also muessen wir die Default-Eigenschaft kurzfristig // aufheben. mp_context->set_default_ix(g_illegal_ix); // Default-Wert aufheben read(is,p_matsep); // neuen Default-Wert auslesen mp_context->set_default_ix(m_ix); // Default-Wert reaktivieren } // Spezialfall: vorher global default, jetzt context-default, dann // duerfen wir auf keinen Fall den alten Inhalt wiederherstellen. if (restore) load(old_ix); }
struct babel_route * route_stream_next(struct route_stream *stream) { if(stream->installed) { while(stream->index < route_slots) if(stream->installed == ROUTE_SS_INSTALLED && is_default(routes[stream->index]->src->src_prefix, routes[stream->index]->src->src_plen)) return NULL; else if(routes[stream->index]->installed) break; else stream->index++; if(stream->index < route_slots) return routes[stream->index++]; else return NULL; } else { struct babel_route *next; if(!stream->next) { stream->index++; if(stream->index >= route_slots) return NULL; stream->next = routes[stream->index]; } next = stream->next; stream->next = next->next; return next; } }
AUX_Module::AUX_Module ( ) : JACK_Module ( false ) { is_default( false ); _number = 0; { Port p( this, Port::INPUT, Port::CONTROL, "Gain (dB)" ); p.hints.type = Port::Hints::LOGARITHMIC; p.hints.ranged = true; p.hints.minimum = -70.0f; p.hints.maximum = 6.0f; p.hints.default_value = 0.0f; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } log_create(); color( FL_DARK1 ); copy_label( "Aux" ); }
static int setting_set_exit_action(const TCHAR *service_name, void *param, const TCHAR *name, void *default_value, value_t *value, const TCHAR *additional) { unsigned long exitcode; TCHAR *code; TCHAR action_string[ACTION_LEN]; if (additional) { /* Default action? */ if (is_default(additional)) code = 0; else { if (str_number(additional, &exitcode)) return -1; code = (TCHAR *) additional; } } HKEY key = open_registry(service_name, name, KEY_WRITE); if (! key) return -1; long error; int ret = 1; /* Resetting to default? */ if (value && value->string) _sntprintf_s(action_string, _countof(action_string), _TRUNCATE, _T("%s"), value->string); else { if (code) { /* Delete explicit action. */ error = RegDeleteValue(key, code); RegCloseKey(key); if (error == ERROR_SUCCESS || error == ERROR_FILE_NOT_FOUND) return 0; print_message(stderr, NSSM_MESSAGE_REGDELETEVALUE_FAILED, code, service_name, error_string(error)); return -1; } else { /* Explicitly keep the default action. */ if (default_value) _sntprintf_s(action_string, _countof(action_string), _TRUNCATE, _T("%s"), (TCHAR *) default_value); ret = 0; } } /* Validate the string. */ for (int i = 0; exit_action_strings[i]; i++) { if (! _tcsnicmp((const TCHAR *) action_string, exit_action_strings[i], ACTION_LEN)) { if (default_value && str_equiv(action_string, (TCHAR *) default_value)) ret = 0; if (RegSetValueEx(key, code, 0, REG_SZ, (const unsigned char *) exit_action_strings[i], (unsigned long) (_tcslen(action_string) + 1) * sizeof(TCHAR)) != ERROR_SUCCESS) { print_message(stderr, NSSM_MESSAGE_SETVALUE_FAILED, code, service_name, error_string(GetLastError())); RegCloseKey(key); return -1; } RegCloseKey(key); return ret; } } print_message(stderr, NSSM_MESSAGE_INVALID_EXIT_ACTION, action_string); for (int i = 0; exit_action_strings[i]; i++) _ftprintf(stderr, _T("%s\n"), exit_action_strings[i]); return -1; }
static int setting_set_affinity(const TCHAR *service_name, void *param, const TCHAR *name, void *default_value, value_t *value, const TCHAR *additional) { HKEY key = (HKEY) param; if (! key) return -1; long error; __int64 mask; __int64 system_affinity = 0LL; if (value && value->string) { DWORD_PTR affinity; if (! GetProcessAffinityMask(GetCurrentProcess(), &affinity, (DWORD_PTR *) &system_affinity)) system_affinity = ~0; if (is_default(value->string) || str_equiv(value->string, NSSM_AFFINITY_ALL)) mask = 0LL; else if (affinity_string_to_mask(value->string, &mask)) { print_message(stderr, NSSM_MESSAGE_BOGUS_AFFINITY_MASK, value->string, num_cpus() - 1); return -1; } } else mask = 0LL; if (! mask) { error = RegDeleteValue(key, name); if (error == ERROR_SUCCESS || error == ERROR_FILE_NOT_FOUND) return 0; print_message(stderr, NSSM_MESSAGE_REGDELETEVALUE_FAILED, name, service_name, error_string(error)); return -1; } /* Canonicalise. */ TCHAR *canon = 0; if (affinity_mask_to_string(mask, &canon)) canon = value->string; __int64 effective_affinity = mask & system_affinity; if (effective_affinity != mask) { /* Requested CPUs did not intersect with available CPUs? */ if (! effective_affinity) mask = effective_affinity = system_affinity; TCHAR *system = 0; if (! affinity_mask_to_string(system_affinity, &system)) { TCHAR *effective = 0; if (! affinity_mask_to_string(effective_affinity, &effective)) { print_message(stderr, NSSM_MESSAGE_EFFECTIVE_AFFINITY_MASK, value->string, system, effective); HeapFree(GetProcessHeap(), 0, effective); } HeapFree(GetProcessHeap(), 0, system); } } if (RegSetValueEx(key, name, 0, REG_SZ, (const unsigned char *) canon, (unsigned long) (_tcslen(canon) + 1) * sizeof(TCHAR)) != ERROR_SUCCESS) { if (canon != value->string) HeapFree(GetProcessHeap(), 0, canon); log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_SETVALUE_FAILED, name, error_string(GetLastError()), 0); return -1; } if (canon != value->string) HeapFree(GetProcessHeap(), 0, canon); return 1; }
PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL void Flag::print_on(outputStream* st, bool withComments) { // Don't print notproduct and develop flags in a product build. if (is_constant_in_binary()) { return; } st->print("%9s %-40s %c= ", _type, _name, (!is_default() ? ':' : ' ')); if (is_bool()) { st->print("%-16s", get_bool() ? "true" : "false"); } if (is_intx()) { st->print("%-16ld", get_intx()); } if (is_uintx()) { st->print("%-16lu", get_uintx()); } if (is_uint64_t()) { st->print("%-16lu", get_uint64_t()); } if (is_double()) { st->print("%-16f", get_double()); } if (is_ccstr()) { const char* cp = get_ccstr(); if (cp != NULL) { const char* eol; while ((eol = strchr(cp, '\n')) != NULL) { char format_buffer[FORMAT_BUFFER_LEN]; size_t llen = pointer_delta(eol, cp, sizeof(char)); jio_snprintf(format_buffer, FORMAT_BUFFER_LEN, "%%." SIZE_FORMAT "s", llen); PRAGMA_DIAG_PUSH PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL st->print(format_buffer, cp); PRAGMA_DIAG_POP st->cr(); cp = eol+1; st->print("%5s %-35s += ", "", _name); } st->print("%-16s", cp); } else st->print("%-16s", ""); } st->print("%-20s", " "); print_kind(st); if (withComments) { #ifndef PRODUCT st->print("%s", _doc); #endif } st->cr(); }
bool JACK_Module::configure_inputs ( int n ) { if ( n > 0 ) { if ( is_default() ) control_input[0].hints.minimum = 1; output_connection_handle->show(); } int on = audio_input.size(); if ( n > on ) { for ( int i = on; i < n; ++i ) { if ( add_aux_audio_output(_prefix, i ) ) { add_port( Port( this, Port::INPUT, Port::AUDIO ) ); } } } else { for ( int i = on; i > n; --i ) { audio_input.back().disconnect(); audio_input.pop_back(); aux_audio_output.back().jack_port()->shutdown(); delete aux_audio_output.back().jack_port(); aux_audio_output.pop_back(); } } _connection_handle_outputs[0][0] = 0; _connection_handle_outputs[0][1] = aux_audio_output.size(); if ( is_default() ) control_input[0].control_value_no_callback( n ); return true; }
void Module::set ( Log_Entry &e ) { for ( int i = 0; i < e.size(); ++i ) { const char *s, *v; e.get( i, &s, &v ); if ( ! strcmp( s, ":chain" ) ) { /* This trickiness is because we may need to know the name of our chain before we actually get added to it. */ int i; sscanf( v, "%X", &i ); Chain *t = (Chain*)Loggable::find( i ); assert( t ); chain( t ); } } for ( int i = 0; i < e.size(); ++i ) { const char *s, *v; e.get( i, &s, &v ); /* if ( ! strcmp( s, ":name" ) ) */ /* label( v ); */ if ( ! strcmp( s, ":parameter_values" ) ) { set_parameters( v ); } else if ( ! ( strcmp( s, ":is_default" ) ) ) { is_default( atoi( v ) ); } else if ( ! ( strcmp( s, ":active" ) ) ) { bypass( ! atoi( v ) ); } else if ( ! strcmp( s, ":chain" ) ) { int i; sscanf( v, "%X", &i ); Chain *t = (Chain*)Loggable::find( i ); assert( t ); t->add( this ); } } }
static void isis_redist_set(struct isis_area *area, int level, int family, int type, uint32_t metric, const char *routemap, int originate_type) { int protocol = redist_protocol(family); struct isis_redist *redist = get_redist_settings(area, family, type, level); int i; struct route_table *ei_table; struct route_node *rn; struct isis_ext_info *info; redist->redist = (type == DEFAULT_ROUTE) ? originate_type : 1; redist->metric = metric; isis_redist_routemap_set(redist, routemap); if (!area->ext_reach[protocol][level-1]) { area->ext_reach[protocol][level-1] = route_table_init_with_delegate(&isis_redist_rt_delegate); } for (i = 0; i < REDIST_PROTOCOL_COUNT; i++) if (!area->isis->ext_info[i]) { area->isis->ext_info[i] = route_table_init_with_delegate(&isis_redist_rt_delegate); } isis_redist_update_zebra_subscriptions(area->isis); if (type == DEFAULT_ROUTE && originate_type == DEFAULT_ORIGINATE_ALWAYS) isis_redist_ensure_default(area->isis, family); ei_table = get_ext_info(area->isis, family); for (rn = route_top(ei_table); rn; rn = route_next(rn)) { if (!rn->info) continue; info = rn->info; if (type == DEFAULT_ROUTE) { if (!is_default(&rn->p)) continue; } else { if (info->origin != type) continue; } isis_redist_update_ext_reach(area, level, redist, &rn->p, info); } }
bool JACK_Module::configure_outputs ( int n ) { int on = audio_output.size(); if ( n > 0 ) { input_connection_handle->show(); } if ( n > on ) { for ( int i = on; i < n; ++i ) { if ( add_aux_audio_input(_prefix, i ) ) { add_port( Port( this, Port::OUTPUT, Port::AUDIO ) ); } } } else { for ( int i = on; i > n; --i ) { audio_output.back().disconnect(); audio_output.pop_back(); aux_audio_input.back().jack_port()->shutdown(); delete aux_audio_input.back().jack_port(); aux_audio_input.pop_back(); } } if ( is_default() ) control_input[1].control_value_no_callback( n ); if ( n > 0 && is_default() ) { dec_button->show(); inc_button->show(); } return true; }
virtual void print(std::ostream* s, const int depth, const std::string prefix) { if (!s) return; std::string indent(compute_indent(depth), ' '); *s << prefix << indent << _name << " = " << print_value(); if(is_default()) *s << " (Default)"; *s << std::endl; }
void Controller_Module::command_remove ( void ) { if ( is_default() ) fl_alert( "Default modules may not be deleted." ); else { chain()->remove( this ); Fl::delete_widget( this ); } }
void data_type<T>::info ( ostream& os ) const { os << "<field>"; if (!is_default()) os << "<value " << (*mp_value) << ">"; os << (*mp_context); os << "</field>" << endl; }
/** build the context menu */ Fl_Menu_Button & Module::menu ( void ) const { static Fl_Menu_Button m( 0, 0, 0, 0, "Module" ); static Fl_Menu_Button *insert_menu = NULL; if ( ! insert_menu ) { insert_menu = new Fl_Menu_Button( 0, 0, 0, 0 ); insert_menu->add( "Gain", 0, 0 ); insert_menu->add( "Meter", 0, 0 ); insert_menu->add( "Mono Pan", 0, 0 ); insert_menu->add( "Aux", 0, 0 ); insert_menu->add( "Spatializer", 0, 0 ); insert_menu->add( "Plugin", 0, 0 ); insert_menu->callback( &Module::insert_menu_cb, (void*)this ); } m.clear(); m.add( "Insert", 0, &Module::menu_cb, (void*)this, 0); m.add( "Insert", 0, &Module::menu_cb, const_cast< Fl_Menu_Item *>( insert_menu->menu() ), FL_SUBMENU_POINTER ); m.add( "Edit Parameters", ' ', &Module::menu_cb, (void*)this, 0 ); m.add( "Show Analysis", 's', &Module::menu_cb, (void*)this, 0); m.add( "Bypass", 'b', &Module::menu_cb, (void*)this, FL_MENU_TOGGLE | ( bypass() ? FL_MENU_VALUE : 0 ) ); m.add( "Cut", FL_CTRL + 'x', &Module::menu_cb, (void*)this, is_default() ? FL_MENU_INACTIVE : 0 ); m.add( "Copy", FL_CTRL + 'c', &Module::menu_cb, (void*)this, is_default() ? FL_MENU_INACTIVE : 0 ); m.add( "Paste", FL_CTRL + 'v', &Module::menu_cb, (void*)this, _copied_module_empty ? 0 : FL_MENU_INACTIVE ); m.add( "Remove", FL_Delete, &Module::menu_cb, (void*)this ); // menu_set_callback( menu, &Module::menu_cb, (void*)this ); m.callback( &Module::insert_menu_cb, (void*)this ); return m; }
void data_type<T>::free() { if (!is_default()) { if (is_shared()) copy_default(); else { m_repository.free(m_ix); load_default(); } } }
static int route_compare(const unsigned char *prefix, unsigned char plen, const unsigned char *src_prefix, unsigned char src_plen, struct babel_route *route) { int i; int is_ss = !is_default(src_prefix, src_plen); int is_ss_rt = !is_default(route->src->src_prefix, route->src->src_plen); /* Put all source-specific routes in the front of the list. */ if(!is_ss && is_ss_rt) { return 1; } else if(is_ss && !is_ss_rt) { return -1; } i = memcmp(prefix, route->src->prefix, 16); if(i != 0) return i; if(plen < route->src->plen) return -1; if(plen > route->src->plen) return 1; if(is_ss) { i = memcmp(src_prefix, route->src->src_prefix, 16); if(i != 0) return i; if(src_plen < route->src->src_plen) return -1; if(src_plen > route->src->src_plen) return 1; } return 0; }
/* Handle notification about route being added */ void isis_redist_add(int type, struct prefix *p, u_char distance, uint32_t metric) { int family = p->family; struct route_table *ei_table = get_ext_info(isis, family); struct route_node *ei_node; struct isis_ext_info *info; struct listnode *node; struct isis_area *area; int level; struct isis_redist *redist; char debug_buf[BUFSIZ]; prefix2str(p, debug_buf, sizeof(debug_buf)); zlog_debug("%s: New route %s from %s.", __func__, debug_buf, zebra_route_string(type)); if (!ei_table) { zlog_warn("%s: External information table not initialized.", __func__); return; } ei_node = route_node_get(ei_table, p); if (ei_node->info) route_unlock_node(ei_node); else ei_node->info = XCALLOC(MTYPE_ISIS, sizeof(struct isis_ext_info)); info = ei_node->info; info->origin = type; info->distance = distance; info->metric = metric; if (is_default(p)) type = DEFAULT_ROUTE; for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) for (level = 1; level <= ISIS_LEVELS; level++) { redist = get_redist_settings(area, family, type, level); if (!redist->redist) continue; isis_redist_update_ext_reach(area, level, redist, p, info); } }
void Module::get ( Log_Entry &e ) const { // e.add( ":name", label() ); // e.add( ":color", (unsigned long)color()); { char *s = get_parameters(); if ( strlen( s ) ) e.add( ":parameter_values", s ); delete[] s; } e.add( ":is_default", is_default() ); e.add( ":chain", chain() ); e.add( ":active", ! bypass() ); }
static int check_specific_first(void) { /* All source-specific routes are in front of the list */ int specific = 1; int i; for(i = 0; i < route_slots; i++) { if(is_default(routes[i]->src->src_prefix, routes[i]->src->src_plen)) { specific = 0; } else if(!specific) { return 0; } } return 1; }
void Module::draw_label ( void ) { int tw, th, tx, ty; bbox( tx, ty, tw, th ); const char *lp = label(); int l = strlen( label() ); Fl_Color c = FL_FOREGROUND_COLOR; if ( bypass() || ! active() ) c = FL_BLACK; fl_color( fl_contrast( c, is_default() ? FL_BLACK : color() ) ); char *s = NULL; if ( l > 10 ) { s = new char[l]; char *sp = s; for ( ; *lp; ++lp ) switch ( *lp ) { case 'i': case 'e': case 'o': case 'u': case 'a': break; default: *(sp++) = *lp; } *sp = '\0'; } if ( l > 20 ) fl_font( FL_HELVETICA, 10 ); else fl_font( FL_HELVETICA, 14 ); fl_draw( s ? s : lp, tx, ty, tw, th, (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP ) ); if ( s ) delete[] s; }
virtual void read(boost::shared_ptr<nscapi::settings_proxy> proxy, bool oneliner, bool is_sample) { parent::read(proxy, oneliner, is_sample); nscapi::settings_helper::settings_registry settings(proxy); nscapi::settings_helper::path_extension root_path = settings.path(get_path()); if (is_sample) root_path.set_sample(); if (is_default()) { root_path.add_key() ("path", sh::string_fun_key(boost::bind(&parent::set_property_string, this, "perf path", _1), "system.${hostname}.${check_alias}.${perf_alias}"), "PATH FOR METRICS", "Path mapping for metrics") ("status path", sh::string_fun_key(boost::bind(&parent::set_property_string, this, "status path", _1), "system.${hostname}.${check_alias}.status"), "PATH FOR STATUS", "Path mapping for status") ("send perfdata", sh::bool_fun_key(boost::bind(&parent::set_property_bool, this, "send perfdata", _1), true), "SEND PERF DATA", "Send performance data to this server") ("send status", sh::bool_fun_key(boost::bind(&parent::set_property_bool, this, "send status", _1), true), "SEND STATUS", "Send status data to this server") ; } else { root_path.add_key() ("path", sh::string_fun_key(boost::bind(&parent::set_property_string, this, "perf path", _1)), "PATH FOR METRICS", "Path mapping for metrics") ("status path", sh::string_fun_key(boost::bind(&parent::set_property_string, this, "status path", _1)), "PATH FOR STATUS", "Path mapping for status") ("send perfdata", sh::bool_fun_key(boost::bind(&parent::set_property_bool, this, "send perfdata", _1)), "SEND PERF DATA", "Send performance data to this server") ("send status", sh::bool_fun_key(boost::bind(&parent::set_property_bool, this, "send status", _1)), "SEND STATUS", "Send status data to this server") ; } settings.register_all(); settings.notify(); }
static void isis_redist_unset(struct isis_area *area, int level, int family, int type) { struct isis_redist *redist = get_redist_settings(area, family, type, level); struct route_table *er_table = get_ext_reach(area, family, level); struct route_node *rn; struct isis_ext_info *info; if (!redist->redist) return; redist->redist = 0; if (!er_table) { zlog_warn("%s: External reachability table uninitialized.", __func__); return; } for (rn = route_top(er_table); rn; rn = route_next(rn)) { if (!rn->info) continue; info = rn->info; if (type == DEFAULT_ROUTE) { if (!is_default(&rn->p)) continue; } else { if (info->origin != type) continue; } XFREE(MTYPE_ISIS, rn->info); route_unlock_node(rn); } lsp_regenerate_schedule(area, level, 0); isis_redist_update_zebra_subscriptions(area->isis); }
void Module::draw_box ( void ) { fl_color( fl_contrast( FL_FOREGROUND_COLOR, color() ) ); int tw, th, tx, ty; tw = w(); th = h(); ty = y(); tx = x(); fl_push_clip( tx, ty, tw, th ); Fl_Color c = is_default() ? FL_BLACK : color(); c = active() && ! bypass() ? c : fl_inactive( c ); int spacing = w() / instances(); for ( int i = instances(); i--; ) { fl_draw_box( box(), tx + (spacing * i), ty, tw / instances(), th, Fl::belowmouse() == this ? fl_lighter( c ) : c ); } if ( this == Fl::focus() ) { fl_draw_box( FL_UP_FRAME, x(), y(), w(), h(), selection_color() ); } if ( audio_input.size() && audio_output.size() ) { /* maybe draw control indicators */ if ( control_input.size() ) fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + 4, 5, 5, is_being_controlled() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); if ( control_output.size() ) fl_draw_box( FL_ROUNDED_BOX, tx + tw - 8, ty + 4, 5, 5, is_controlling() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); } Fl_Group::draw_children(); fl_pop_clip(); }
static int setting_get_exit_action(const TCHAR *service_name, void *param, const TCHAR *name, void *default_value, value_t *value, const TCHAR *additional) { unsigned long exitcode = 0; unsigned long *code = 0; if (additional) { if (! is_default(additional)) { if (str_number(additional, &exitcode)) return -1; code = &exitcode; } } TCHAR action_string[ACTION_LEN]; bool default_action; if (get_exit_action(service_name, code, action_string, &default_action)) return -1; value_from_string(name, value, action_string); if (default_action && ! _tcsnicmp((const TCHAR *) action_string, (TCHAR *) default_value, ACTION_LEN)) return 0; return 1; }
/** build the context menu for this control */ Fl_Menu_Button & Controller_Module::menu ( void ) { static Fl_Menu_Button m( 0, 0, 0, 0, "Controller" ); m.clear(); if ( mode() == GUI ) { add_osc_peers_to_menu( &m, "Connect To" ); add_osc_connections_to_menu( &m, "Disconnect From" ); } m.add( "Mode/GUI + OSC", 0, 0, 0, FL_MENU_RADIO | ( mode() == GUI ? FL_MENU_VALUE : 0 )); m.add( "Mode/Control Voltage (JACK)", 0, 0, 0, FL_MENU_RADIO | ( mode() == CV ? FL_MENU_VALUE : 0 )); m.add( "Remove", 0, 0, 0, is_default() ? FL_MENU_INACTIVE : 0 ); // menu_set_callback( m.items(), &Controller_Module::menu_cb, (void*)this ); m.callback( &Controller_Module::menu_cb, (void*)this ); // m.copy( items, (void*)this ); return m; }
int main(int argc, char **argv) { bool have_format = false; bool infinity = false; bool nofinalnl = false; bool randomize = false; bool use_random = false; int ch; int mask = 0; int n = 0; double begin = BEGIN_DEF; double divisor; double ender = ENDER_DEF; double s = STEP_DEF; double x, y; long i; long reps = REPS_DEF; while ((ch = getopt(argc, argv, "b:cnp:rs:w:")) != -1) switch (ch) { case 'b': boring = true; /* FALLTHROUGH */ case 'w': if (strlcpy(format, optarg, sizeof(format)) >= sizeof(format)) errx(1, "-%c word too long", ch); have_format = true; break; case 'c': chardata = true; break; case 'n': nofinalnl = true; break; case 'p': prec = atoi(optarg); if (prec < 0) errx(1, "bad precision value"); have_format = true; break; case 'r': randomize = true; break; case 's': sepstring = optarg; break; default: usage(); } argc -= optind; argv += optind; switch (argc) { /* examine args right to left, falling thru cases */ case 4: if (!is_default(argv[3])) { if (!sscanf(argv[3], "%lf", &s)) errx(1, "bad s value: %s", argv[3]); mask |= HAVE_STEP; if (randomize) use_random = true; } /* FALLTHROUGH */ case 3: if (!is_default(argv[2])) { if (!sscanf(argv[2], "%lf", &ender)) ender = argv[2][strlen(argv[2])-1]; mask |= HAVE_ENDER; if (prec < 0) n = getprec(argv[2]); } /* FALLTHROUGH */ case 2: if (!is_default(argv[1])) { if (!sscanf(argv[1], "%lf", &begin)) begin = argv[1][strlen(argv[1])-1]; mask |= HAVE_BEGIN; if (prec < 0) prec = getprec(argv[1]); if (n > prec) /* maximum precision */ prec = n; } /* FALLTHROUGH */ case 1: if (!is_default(argv[0])) { if (!sscanf(argv[0], "%ld", &reps)) errx(1, "bad reps value: %s", argv[0]); mask |= HAVE_REPS; } break; case 0: usage(); default: errx(1, "too many arguments. What do you mean by %s?", argv[4]); } getformat(); if (prec == -1) prec = 0; while (mask) /* 4 bit mask has 1's where last 4 args were given */ switch (mask) { /* fill in the 0's by default or computation */ case HAVE_STEP: case HAVE_ENDER: case HAVE_ENDER | HAVE_STEP: case HAVE_BEGIN: case HAVE_BEGIN | HAVE_STEP: reps = REPS_DEF; mask |= HAVE_REPS; break; case HAVE_BEGIN | HAVE_ENDER: s = ender > begin ? 1 : -1; mask |= HAVE_STEP; break; case HAVE_BEGIN | HAVE_ENDER | HAVE_STEP: if (randomize) reps = REPS_DEF; else if (s == 0.0) reps = 0; else reps = (ender - begin + s) / s; if (reps <= 0) errx(1, "impossible stepsize"); mask = 0; break; case HAVE_REPS: case HAVE_REPS | HAVE_STEP: begin = BEGIN_DEF; mask |= HAVE_BEGIN; break; case HAVE_REPS | HAVE_ENDER: s = STEP_DEF; mask = HAVE_REPS | HAVE_ENDER | HAVE_STEP; break; case HAVE_REPS | HAVE_ENDER | HAVE_STEP: if (randomize) begin = BEGIN_DEF; else if (reps == 0) errx(1, "must specify begin if reps == 0"); begin = ender - reps * s + s; mask = 0; break; case HAVE_REPS | HAVE_BEGIN: s = STEP_DEF; mask = HAVE_REPS | HAVE_BEGIN | HAVE_STEP; break; case HAVE_REPS | HAVE_BEGIN | HAVE_STEP: if (randomize) ender = ENDER_DEF; else ender = begin + reps * s - s; mask = 0; break; case HAVE_REPS | HAVE_BEGIN | HAVE_ENDER: if (reps == 0) errx(1, "infinite sequences cannot be bounded"); else if (reps == 1) s = 0.0; else s = (ender - begin) / (reps - 1); mask = 0; break; case HAVE_REPS | HAVE_BEGIN | HAVE_ENDER | HAVE_STEP: /* if reps given and implied, */ if (!randomize && s != 0.0) { long t = (ender - begin + s) / s; if (t <= 0) errx(1, "impossible stepsize"); if (t < reps) /* take lesser */ reps = t; } mask = 0; break; default: errx(1, "bad mask"); } if (reps == 0) infinity = true; if (randomize) { if (use_random) { srandom((unsigned long)s); divisor = (double)INT32_MAX + 1; } else divisor = (double)UINT32_MAX + 1; /* * Attempt to DWIM when the user has specified an * integer range within that of the random number * generator: distribute the numbers equally in * the range [begin .. ender]. Jot's default %.0f * format would make the appearance of the first and * last specified value half as likely as the rest. */ if (!have_format && prec == 0 && begin >= 0 && begin < divisor && ender >= 0 && ender < divisor) { if (begin <= ender) ender += 1; else begin += 1; nosign = true; intdata = true; (void)strlcpy(format, chardata ? "%c" : "%u", sizeof(format)); } x = ender - begin; for (i = 1; i <= reps || infinity; i++) { if (use_random) y = random() / divisor; else y = arc4random() / divisor; if (putdata(y * x + begin, !(reps - i))) errx(1, "range error in conversion"); } } else for (i = 1, x = begin; i <= reps || infinity; i++, x += s) if (putdata(x, !(reps - i))) errx(1, "range error in conversion"); if (!nofinalnl) putchar('\n'); exit(0); }
Spatializer_Module::Spatializer_Module ( ) : JACK_Module ( false ) { is_default( false ); _panner = 0; _early_panner = 0; { Port p( this, Port::INPUT, Port::CONTROL, "Azimuth" ); p.hints.type = Port::Hints::LINEAR; p.hints.ranged = true; p.hints.minimum = -180.0f; p.hints.maximum = 180.0f; p.hints.default_value = 0.0f; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } { Port p( this, Port::INPUT, Port::CONTROL, "Elevation" ); p.hints.type = Port::Hints::LINEAR; p.hints.ranged = true; p.hints.minimum = -90.0f; p.hints.maximum = 90.0f; p.hints.default_value = 0.0f; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } { Port p( this, Port::INPUT, Port::CONTROL, "Radius" ); p.hints.type = Port::Hints::LINEAR; p.hints.ranged = true; p.hints.minimum = 0.0f; p.hints.maximum = max_distance; p.hints.default_value = 1.0f; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } { Port p( this, Port::INPUT, Port::CONTROL, "Highpass (Hz)" ); p.hints.type = Port::Hints::LINEAR; p.hints.ranged = true; p.hints.minimum = 0.0f; p.hints.maximum = 600.0f; p.hints.default_value = 0.0f; p.hints.visible = false; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } { Port p( this, Port::INPUT, Port::CONTROL, "Width" ); p.hints.type = Port::Hints::LINEAR; p.hints.ranged = true; p.hints.minimum = -90.0f; p.hints.maximum = 90.0f; p.hints.default_value = 90.0f; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } { Port p( this, Port::INPUT, Port::CONTROL, "Angle" ); p.hints.type = Port::Hints::LINEAR; p.hints.ranged = true; p.hints.minimum = -180.0f; p.hints.maximum = +180.0f; p.hints.default_value = 0.0f; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } { Port p( this, Port::INPUT, Port::CONTROL, "Advanced Options" ); p.hints.type = Port::Hints::BOOLEAN; p.hints.ranged = true; p.hints.minimum = 0.0f; p.hints.maximum = 1.0f; p.hints.default_value = 0.0f; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } { Port p( this, Port::INPUT, Port::CONTROL, "Speed of Sound" ); p.hints.type = Port::Hints::BOOLEAN; p.hints.ranged = true; p.hints.minimum = 0.0f; p.hints.maximum = 1.0f; p.hints.default_value = 1.0f; p.hints.visible = false; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } { Port p( this, Port::INPUT, Port::CONTROL, "Late Gain (dB)" ); p.hints.type = Port::Hints::LOGARITHMIC; p.hints.ranged = true; p.hints.minimum = -70.0f; p.hints.maximum = 6.0f; p.hints.default_value = 0.0f; p.hints.visible = false; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } { Port p( this, Port::INPUT, Port::CONTROL, "Early Gain (dB)" ); p.hints.type = Port::Hints::LOGARITHMIC; p.hints.ranged = true; p.hints.minimum = -70.0f; p.hints.maximum = 6.0f; p.hints.default_value = 0.0f; p.hints.visible = false; p.connect_to( new float ); p.control_value( p.hints.default_value ); add_port( p ); } log_create(); _panner = new ambisonic_panner(); _early_panner = new ambisonic_panner(); labelsize(9); color( FL_DARK1 ); copy_label( "Spatializer" ); align(FL_ALIGN_LEFT|FL_ALIGN_TOP|FL_ALIGN_INSIDE); gain_smoothing.sample_rate( sample_rate() ); late_gain_smoothing.sample_rate( sample_rate() ); early_gain_smoothing.sample_rate( sample_rate() ); delay_smoothing.cutoff( 0.5f ); delay_smoothing.sample_rate( sample_rate() ); }
size_t borderId(const odf_reader::style_table_cell_properties_attlist * cellProp, bool & is_default_val) { xlsx_border border; border.left = xlsx_border_edge(); border.right = xlsx_border_edge(); border.top = xlsx_border_edge(); border.bottom = xlsx_border_edge(); if (cellProp) { const common_border_attlist & odfBordersAttr = cellProp->common_border_attlist_; process_border(*border.left, odfBordersAttr.fo_border_); process_border(*border.right, odfBordersAttr.fo_border_); process_border(*border.top, odfBordersAttr.fo_border_); process_border(*border.bottom, odfBordersAttr.fo_border_); process_border(*border.left, odfBordersAttr.fo_border_left_); process_border(*border.right, odfBordersAttr.fo_border_right_); process_border(*border.top, odfBordersAttr.fo_border_top_); process_border(*border.bottom, odfBordersAttr.fo_border_bottom_); if (check_border(cellProp->style_diagonal_bl_tr_)) { border.diagonal = xlsx_border_edge(); _CP_OPT(border_style) borderStyle(*cellProp->style_diagonal_bl_tr_); process_border(*border.diagonal, borderStyle); border.diagonalUp = true; } if (check_border(cellProp->style_diagonal_tl_br_)) { if (!border.diagonal) border.diagonal = xlsx_border_edge(); _CP_OPT(border_style) borderStyle (*cellProp->style_diagonal_tl_br_); process_border(*border.diagonal, borderStyle); border.diagonalDown = true; } } if (is_default(border)) { is_default_val = true; return 0; } else { is_default_val = false; xlsx_borders_array::const_iterator i = borders_.find(border); if (i != borders_.end()) { return i->index; } else { border.index = borders_.size(); borders_.insert(border); //borders_.push_back(border); return border.index; } } }