Exemple #1
0
// ========================================================================
	void cfg_ring::OnOK()
// ========================================================================
{
int		from=0,to=0;

	UpdateData(1);
	if (m_nr_m1.IsEmpty() || m_pause_m1.IsEmpty() || m_nr_m2.IsEmpty() ||
		m_pause_m2.IsEmpty() || m_nr_isdn.IsEmpty() || m_pause_isdn.IsEmpty())
			ERR_MSG_RET("E_PFUAE");
	sscanf(m_from,"%d",&from);
	sscanf(m_to,"%d",&to);
	if (m_for1 || m_for2)
	{
		if (from<1)	ERR_MSG_RET("E_WFSPCA");
		if (to<1 || to<from)	ERR_MSG_RET("E_WFSPCA");
	}

	set_cfg(CFG_INCOMIN,"Modem1",m_nr_m1+","+m_pause_m1);
	set_cfg(CFG_INCOMIN,"Modem2",m_nr_m2+","+m_pause_m2);
	set_cfg(CFG_INCOMIN,"ISDN",m_nr_isdn+","+m_pause_isdn);
	
	income_times.defaultindex=m_disable.GetCheck();
	income_times.reserved3=0;
	if (m_for1)	income_times.reserved3 |=1;
	if (m_for2)	income_times.reserved3 |=2;
	income_times.reserved4=from;
	income_times.reserved5=to;
	income_times.SaveToFile("incomet.cfg");
	gIncomeDevicesHaveChanged=1;
	
	if(m_bCloseOnOk)
		CDialog::OnOK();
}
Exemple #2
0
static int scn_obj(char *js, jsmntok_t * t, 
		mbag_t mbag,
		cw_itemdefheap_t defs, 
		const char *objkey)
{
	int i;

	if (t->type != JSMN_OBJECT) {
		fprintf(stderr,"Error reading json cfgp: Not an object\n");
		return 0;
	}

	int j = 1;
	for (i = 0; i < t->size; i++) {

//		j += scn_obj0(js, t + j, defs, mbag,objkey,type);

		jsmntok_t * to=t+j;

		*(js + to->end) = 0;
		const char *key = js + to->start;
		*(js + (to + 1)->end) = 0;
		const char * val = js+(to+1)->start;

		//printf("Key: %s Val: %s\n",key,val);
		

		if ((to+1)->type == JSMN_OBJECT) {
			if (objkey) {
				fprintf(stderr,"Too deep: %s %s\n",objkey,key);

			}
			else{

				/* special case: radios */
				if (strcmp(key,"radios")==0){
					printf("Radios found\n");
					scn_radios(js,to+1);	
				}
				else{
					scn_obj(js,to+1,mbag,defs,key);	
				}
			}

		}
		else{
			if (objkey)
				set_cfg(mbag,defs,objkey,key,val);
			else
				set_cfg(mbag,defs,key,NULL,val);

		}

		j+=skip(to+1);

	}
	return 0;
}
Exemple #3
0
static int _set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
			       char *obuf, int obuf_len, bool test)
{
	int value;
	int current_value;
	char arg_path[256];

	if (cmd->cmd != cmd_settlv)
		return cmd_invalid;

	switch (cmd->tlvid) {
	case (OUI_CEE_DCBX << 8) | 1:
	case (OUI_CEE_DCBX << 8) | 2:
		break;
	case INVALID_TLVID:
		return cmd_invalid;
	default:
		return cmd_not_applicable;
	}

	if (!strcasecmp(argvalue, VAL_YES))
		value = 1;
	else if (!strcasecmp(argvalue, VAL_NO))
		value = 0;
	else
		return cmd_invalid;

	if (test)
		return cmd_success;

	current_value = is_tlv_txenabled(cmd->ifname, cmd->type, cmd->tlvid);

	snprintf(obuf, obuf_len, "enabled = %s\n", value ? "yes" : "no");

	if (current_value == value)
		return cmd_success;

	snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
		 cmd->tlvid, arg);

	if (set_cfg(cmd->ifname, cmd->type, arg_path, &value,
		    CONFIG_TYPE_BOOL))
		return cmd_failed;

	dont_advertise_dcbx_all(cmd->ifname, value);
	somethingChangedLocal(cmd->ifname, cmd->type);

	return cmd_success;
}
Exemple #4
0
static int gpmc_timings_to_config(struct gpmc_config *gpmc_config, const struct gpmc_timings *t)
{
	int div, ret = 0;

	div = gpmc_calc_divider(t->sync_clk);
	if (div < 0)
		return div;

	ret |= set_cfg(gpmc_config, 0, 18, 19, t->wait_monitoring);
	ret |= set_cfg(gpmc_config, 0, 25, 26, t->clk_activation);

	ret |= set_cfg(gpmc_config, 1,  0,  3, t->cs_on);
	ret |= set_cfg(gpmc_config, 1,  8, 12, t->cs_rd_off);
	ret |= set_cfg(gpmc_config, 1, 16, 20, t->cs_wr_off);

	ret |= set_cfg(gpmc_config, 2,  0,  3, t->adv_on);
	ret |= set_cfg(gpmc_config, 2,  8, 12, t->adv_rd_off);
	ret |= set_cfg(gpmc_config, 2, 16, 20, t->adv_wr_off);

	ret |= set_cfg(gpmc_config, 3,  0,  3, t->oe_on);
	ret |= set_cfg(gpmc_config, 3,  8, 12, t->oe_off);
	ret |= set_cfg(gpmc_config, 3, 16, 19, t->we_on);
	ret |= set_cfg(gpmc_config, 3, 24, 28, t->we_off);

	ret |= set_cfg(gpmc_config, 4,  0,  4, t->rd_cycle);
	ret |= set_cfg(gpmc_config, 4,  8, 12, t->wr_cycle);
	ret |= set_cfg(gpmc_config, 4, 16, 20, t->access);

	ret |= set_cfg(gpmc_config, 4, 24, 27, t->page_burst_access);

	ret |= set_cfg(gpmc_config, 5, 0, 3, t->bus_turnaround);
	ret |= set_cfg(gpmc_config, 5, 8, 11, t->cycle2cycle_delay);
	ret |= set_cfg(gpmc_config, 5, 16, 19, t->wr_data_mux_bus);
	ret |= set_cfg(gpmc_config, 5, 24, 28, t->wr_access);

	if (ret)
		return ret;

	gpmc_cs_bool_timings(gpmc_config, &t->bool_timings);

	return 0;
}
Exemple #5
0
int joyai_config(int joy)
{
    BOOL running = TRUE;
    keysym_type *keysym = (joy == 2) ? keysym_2 : keysym_1;
    ULONG signals;

    if (!amigainput_lib_loaded) {
        return -1;
    }

    if (CTX == NULL) {
        return -1;
    }

    get_cfg(joy);
    ai_release();

    memset(&devices, 0, sizeof(devices));
    memset(&inputs, 0, sizeof(inputs));

    if (joy_id[joy - 1] != -1) {
        ai_handle[0] = AIN_ObtainDevice(CTX, joy_id[joy - 1]);
        if (ai_handle[0] != NULL) {
            AIN_ReleaseDevice(CTX, ai_handle[0]);
            ai_handle[0] = NULL;
        } else {
            joy_id[joy - 1] = -1;
        }
    }

    devices.ids[devices.count] = -1;
    devices.names[devices.count] = lib_stralloc("-");
    devices.count++;

    default_id = joy_id[joy - 1];
    default_count = 0;

    AIN_EnumDevices(CTX, enumfunc, &devices);

    update_inputs(joy_id[joy - 1]);

    {
        APTR label, text[NUM_KEYSYM], button, app, main_group, window, ok, cancel, Odevice, Oinput[NUM_KEYSYM];

        app = ApplicationObject,
                MUIA_Application_Author, "Mathias Roslund & Marco van den Heuvel",
                MUIA_Application_Base, KEYNAME,
                MUIA_Application_Title, KEYNAME,
                MUIA_Application_Version, "$VER: " KEYNAME " v1.0",
                MUIA_Application_Copyright, "Mathias Roslund & Marco van den Heuvel",
                MUIA_Application_Description, "Versatile Commodore Emulator",
                SubWindow, window = WindowObject,
                MUIA_Window_Title, KEYNAME,
                MUIA_Window_ID, MAKE_ID('0', 'W', 'I', 'N'),
                MUIA_Window_Screen, canvaslist->os->screen,
                WindowContents, VGroup,
                Child, HGroup,
                Child, TextObject,
                MUIA_Text_PreParse, "\033r",
                MUIA_Text_Contents, "AI Device",
                MUIA_Weight, 0,
                MUIA_InnerLeft, 0,
                MUIA_InnerRight, 0,
                End,
                Child, Odevice = CycleObject,
                MUIA_Cycle_Entries, devices.names,
	          MUIA_Cycle_Active, default_count,
                End,
                End,
                Child, main_group = ColGroup(4),
                End,
                Child, HGroup,
                Child, ok = TextObject,
                ButtonFrame,
                MUIA_Background, MUII_ButtonBack,
                MUIA_Text_Contents, "Ok",
                MUIA_Text_PreParse, "\033c",
                MUIA_InputMode, MUIV_InputMode_RelVerify,
                End,
                Child, cancel = TextObject,
                ButtonFrame,
                MUIA_Background, MUII_ButtonBack,
                MUIA_Text_Contents, "Cancel",
                MUIA_Text_PreParse, "\033c",
                MUIA_InputMode, MUIV_InputMode_RelVerify,
                End,
                End,
                End,
                End,
                End;

        if (app) {
            unsigned int i;

            DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
                     app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

            DoMethod(Odevice, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime,
                     app, 2, MUIM_Application_ReturnID, DEV_CHANGE);

            DoMethod(cancel, MUIM_Notify, MUIA_Pressed, FALSE,
                     app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

            DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE,
                     app, 2, MUIM_Application_ReturnID, BTN_OK);

            for (i = 0; i < NUM_KEYSYM; i++) {

                /* label */
                label = TextObject,
                          MUIA_Text_PreParse, "\033r",
                          MUIA_Text_Contents, keysym[i].label,
                          MUIA_InnerLeft, 0,
                          MUIA_InnerRight, 0,
                        End;

                Oinput[i] = CycleObject,
                              MUIA_Cycle_Entries, inputs.names,
                              MUIA_Cycle_Active, offset_to_active(keysym[i].type, keysym[i].offset),
                            End,

                text[i] = TextObject,
                            MUIA_Background, MUII_TextBack,
                            MUIA_Frame, MUIV_Frame_Text,
                            MUIA_Text_Contents, rawkey_to_name(keysym[i].rawkey),
                          End;

                button = TextObject,
                           ButtonFrame,
                           MUIA_Background, MUII_ButtonBack,
                           MUIA_Text_Contents, "Change",
                           MUIA_Text_PreParse, "\033c",
                           MUIA_InputMode, MUIV_InputMode_RelVerify,
                         End;

                DoMethod(button, MUIM_Notify, MUIA_Pressed, FALSE,
                         app, 2, MUIM_Application_ReturnID, (i + 1));

                /* add to window */

                DoMethod(main_group, OM_ADDMEMBER, label);
                DoMethod(main_group, OM_ADDMEMBER, Oinput[i]);
                DoMethod(main_group, OM_ADDMEMBER, text[i]);
                DoMethod(main_group, OM_ADDMEMBER, button);

            }
        }

        if (app) {
            unsigned int i;

            set(window, MUIA_Window_Open, TRUE);
            while (running) {
                unsigned long retval = DoMethod(app, MUIM_Application_Input, &signals);

                switch (retval) {
                    case MUIV_Application_ReturnID_Quit:
                        running = FALSE;
                        break;
                    case BTN_OK:
                        for (i = 0; i < NUM_KEYSYM; i++) {
                            ULONG active;

                            get(Oinput[i], MUIA_Cycle_Active, &active);
                            keysym[i].type = inputs.types[active];
                            keysym[i].offset = inputs.offsets[active];
                        }
                        set_cfg(joy);
                        running = FALSE;
                        break;
                    case DEV_CHANGE:
                        {
                            ULONG active;

                            get(Odevice, MUIA_Cycle_Active, &active);
                            joy_id[joy - 1] = devices.ids[active];
                            update_inputs(joy_id[joy - 1]);
                            for (i = 0; i < NUM_KEYSYM; i++) {
                                set(Oinput[i], MUIA_Cycle_Entries, inputs.names);
                                set(Oinput[i], MUIA_Cycle_Active, 0);
                            }
                        }
                        break;
                    default:
                        if ((retval >= 1) && (retval <= (1 + NUM_KEYSYM))) {
                            int keycode, index, result;
                            result = get_key(joy_id[joy - 1], &keycode, &index);
                            if (result == 1) { /* KEY */
                                keysym[retval - 1].rawkey = keycode;
                                set(text[retval - 1], MUIA_Text_Contents, rawkey_to_name(keycode));
                            } else if (result == 2) { /* AI */
                                index = offset_to_index(index);
                                if (index >= 0) {
                                    set(Oinput[retval - 1], MUIA_Cycle_Active, index);
                                }
                            }
                        }
                        break;
                }
                if (running && signals) {
                    Wait(signals);
                }
            }
            MUI_DisposeObject(app);
        }  
    }

#undef DEV_CHANGE
#undef BTN_OK

    ai_attach();

    return 0;
}
Exemple #6
0
static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
{
	struct dev_context *devc;
	uint64_t tmp_u64, p, q;
	double t_dbl;
	unsigned int i;
	int ret;
	const char *tmp_str;

	devc = sdi->priv;

	if (sdi->status != SR_ST_ACTIVE)
		return SR_ERR_DEV_CLOSED;

	ret = SR_OK;
	switch (id) {
	case SR_CONF_LIMIT_FRAMES:
		devc->limit_frames = g_variant_get_uint64(data);
		break;
	case SR_CONF_TRIGGER_SLOPE:
		tmp_u64 = g_variant_get_uint64(data);
		if (tmp_u64 != 0 && tmp_u64 != 1)
			return SR_ERR;
		g_free(devc->trigger_slope);
		devc->trigger_slope = g_strdup(tmp_u64 ? "POS" : "NEG");
		ret = set_cfg(sdi, ":TRIG:EDGE:SLOP %s", devc->trigger_slope);
		break;
	case SR_CONF_HORIZ_TRIGGERPOS:
		t_dbl = g_variant_get_double(data);
		if (t_dbl < 0.0 || t_dbl > 1.0)
			return SR_ERR;
		devc->horiz_triggerpos = t_dbl;
		/* We have the trigger offset as a percentage of the frame, but
		 * need to express this in seconds. */
		t_dbl = -(devc->horiz_triggerpos - 0.5) * devc->timebase * NUM_TIMEBASE;
		ret = set_cfg(sdi, ":TIM:OFFS %.6f", t_dbl);
		break;
	case SR_CONF_TIMEBASE:
		g_variant_get(data, "(tt)", &p, &q);
		for (i = 0; i < ARRAY_SIZE(timebases); i++) {
			if (timebases[i][0] == p && timebases[i][1] == q) {
				devc->timebase = (float)p / q;
				ret = set_cfg(sdi, ":TIM:SCAL %.9f", devc->timebase);
				break;
			}
		}
		if (i == ARRAY_SIZE(timebases))
			ret = SR_ERR_ARG;
		break;
	case SR_CONF_TRIGGER_SOURCE:
		tmp_str = g_variant_get_string(data, NULL);
		for (i = 0; i < ARRAY_SIZE(trigger_sources); i++) {
			if (!strcmp(trigger_sources[i], tmp_str)) {
				g_free(devc->trigger_source);
				devc->trigger_source = g_strdup(trigger_sources[i]);
				if (!strcmp(devc->trigger_source, "AC Line"))
					tmp_str = "ACL";
				else if (!strcmp(devc->trigger_source, "CH1"))
					tmp_str = "CHAN1";
				else if (!strcmp(devc->trigger_source, "CH2"))
					tmp_str = "CHAN2";
				else
					tmp_str = (char *)devc->trigger_source;
				ret = set_cfg(sdi, ":TRIG:EDGE:SOUR %s", tmp_str);
				break;
			}
		}
		if (i == ARRAY_SIZE(trigger_sources))
			ret = SR_ERR_ARG;
		break;
	case SR_CONF_VDIV:
		g_variant_get(data, "(tt)", &p, &q);
		for (i = 0; i < ARRAY_SIZE(vdivs); i++) {
			if (vdivs[i][0] != p || vdivs[i][1] != q)
				continue;
			devc->vdiv[0] = devc->vdiv[1] = (float)p / q;
			set_cfg(sdi, ":CHAN1:SCAL %.3f", devc->vdiv[0]);
			ret = set_cfg(sdi, ":CHAN2:SCAL %.3f", devc->vdiv[1]);
			break;
		}
		if (i == ARRAY_SIZE(vdivs))
			ret = SR_ERR_ARG;
		break;
	case SR_CONF_COUPLING:
		/* TODO: Not supporting coupling per channel yet. */
		tmp_str = g_variant_get_string(data, NULL);
		for (i = 0; i < ARRAY_SIZE(coupling); i++) {
			if (!strcmp(tmp_str, coupling[i])) {
				g_free(devc->coupling[0]);
				g_free(devc->coupling[1]);
				devc->coupling[0] = g_strdup(coupling[i]);
				devc->coupling[1] = g_strdup(coupling[i]);
				set_cfg(sdi, ":CHAN1:COUP %s", devc->coupling[0]);
				ret = set_cfg(sdi, ":CHAN2:COUP %s", devc->coupling[1]);
				break;
			}
		}
		if (i == ARRAY_SIZE(coupling))
			ret = SR_ERR_ARG;
		break;
	default:
		ret = SR_ERR_NA;
		break;
	}

	return ret;
}
Exemple #7
0
int GetServerGroupMap(struct servergroup * svcs, char * config, int orch_id) {
	
	MYSQL *mysql;
	MYSQL_ROW  row;
	MYSQL_RES  *res;
	
	
	char * mysql_host = getConfigValue("mysql_host", config);
	char * mysql_user = getConfigValue("mysql_user", config);
	char * mysql_pw = getConfigValue("mysql_pw", config);
	char * mysql_db = getConfigValue("mysql_db", config);
	int i=0;
	
		char * sql, *where;


	set_cfg(config);
	mysql=mysql_init(NULL);
BARTLBY_SQL_PROTECTION_INIT;
		CHK_ERR(mysql,NULL);
	mysql_real_connect(mysql, mysql_host, mysql_user, mysql_pw, NULL, 0, NULL, 0);
		CHK_ERR(mysql,NULL);
      	mysql_select_db(mysql, mysql_db);
      		CHK_ERR(mysql,NULL);
      		

      	if(orch_id > 0) {
      		CHECKED_ASPRINTF(&where, " where orch_id=%d", orch_id);
      	} else {
      		CHECKED_ASPRINTF(&where, " ");
      	}
      	CHECKED_ASPRINTF(&sql, SERVERGROUP_SEL, where);

      	mysql_query(mysql, sql);
		CHK_ERR(mysql,NULL);

		
		free(where);
		free(sql);


	
      	res = mysql_store_result(mysql);
      		CHK_ERR(mysql,NULL);
      	
      	
      	if(mysql_num_rows(res) > 0) {
      		
      		while ( (row=mysql_fetch_row(res)) != NULL) {

  			if(row[0] != NULL) {
      				
      				svcs[i].servergroup_id = atol(row[0]);
      			} else {
      				svcs[i].servergroup_id = -1;    				
      			}
      			
      			if(row[1] != NULL) {
      				
      				sprintf(svcs[i].servergroup_name, "%s", row[1]);
      			} else {
      				sprintf(svcs[i].servergroup_name, "(null)");     				
      			}
      			if(row[2] != NULL) {
      				
      				svcs[i].servergroup_notify = atoi(row[2]);
      			} else {
      				svcs[i].servergroup_notify = 1;    				
      			}
      			if(row[3] != NULL) {
      				
      				svcs[i].servergroup_active = atoi(row[3]);
      			} else {
      				svcs[i].servergroup_active = 1;    				
      			}
      			if(row[4] != NULL) {
      				
      				sprintf(svcs[i].servergroup_members, "%s", row[4]);
      				if(strcmp(svcs[i].servergroup_name, "DEFAULT") == 0) {
      					sprintf(svcs[i].servergroup_members, "%s", "");
      				}      				
      			} else {
      				sprintf(svcs[i].servergroup_members, "(null)");     				
      			}
						if(row[5] != NULL) {
      				svcs[i].servergroup_dead = atoi(row[5]);
      			} else{
      				svcs[i].servergroup_dead = 0;
      			}
      			if(row[6] != NULL) {
      				
      				sprintf(svcs[i].enabled_triggers, "%s", row[6]);
      			} else {
      				sprintf(svcs[i].enabled_triggers, "%s", "");     				
      			}
      			
				svcs[i].orch_id=atoi(row[7]);
      			i++;
      		}
      		
      		mysql_free_result(res);
      		BARTLBY_MYSQL_CLOSE(mysql);
      		free(mysql_host);
		free(mysql_user);
		free(mysql_pw);
		free(mysql_db);
      		return i;
      	} else { 
      		_log(LH_LIB, B_LOG_INFO, "no Servergroups found!");	
      	}
	
	
	
	mysql_free_result(res);
  BARTLBY_MYSQL_CLOSE(mysql);
	free(mysql_host);
	free(mysql_user);
	free(mysql_pw);
	free(mysql_db);
	
	return 0;
	
	
}