Esempio n. 1
0
static int vscode_parse_initialize_request(json_value *js, ProtocolMessage *msg,
                                           FILE *log) {
  // {"type":"request","seq":1,"command":"initialize","arguments":{"adapterID":"lua","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true}}
  json_value *args = get_object_value(js, "arguments", log);
  if (args == NULL) return VSCODE_UNKNOWN_REQUEST;
  const char *adapterID = get_string_value(args, "adapterID", log);
  if (adapterID == NULL || strcmp(adapterID, "lua") != 0) {
    fprintf(log, "Unknown adapterID '%s' in initialize command\n",
            adapterID != NULL ? adapterID : "null");
    return VSCODE_UNKNOWN_REQUEST;
  }
  strncpy(msg->u.Request.u.InitializeRequest.adapterID, adapterID,
          sizeof msg->u.Request.u.InitializeRequest.adapterID);
  const char *pathFormat = get_string_value(args, "pathFormat", log);
  if (pathFormat != NULL && strcmp(pathFormat, "path") != 0) {
    fprintf(log, "Unsupported pathFormat '%s' in initialize command\n",
            pathFormat != NULL ? pathFormat : "null");
    return VSCODE_UNKNOWN_REQUEST;
  }
  if (pathFormat)
    strncpy(msg->u.Request.u.InitializeRequest.pathFormat, pathFormat,
            sizeof msg->u.Request.u.InitializeRequest.pathFormat);
  int found = 0;
  msg->u.Request.u.InitializeRequest.columnsStartAt1 =
      get_boolean_value(args, "columnsStartAt1", log, &found);
  msg->u.Request.u.InitializeRequest.linesStartAt1 =
      get_boolean_value(args, "linesStartAt1", log, &found);
  msg->u.Request.request_type = VSCODE_INITIALIZE_REQUEST;
  return VSCODE_INITIALIZE_REQUEST;
}
Esempio n. 2
0
bool
ConnectionOptionsAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
{
	fIsNew = isNew;
	fDoesDialOnDemand = fAskBeforeDialing = fDoesAutoRedial = false;
	fSettings = settings;
	fProfile = profile;
	
	if(fConnectionOptionsView)
		fConnectionOptionsView->Reload();
			// reset all views (empty settings)
	
	if(!settings || !profile || isNew)
		return true;
	
	BMessage parameter;
	int32 index = 0;
	const char *value;
	if(FindMessageParameter(PPP_DIAL_ON_DEMAND_KEY, *fSettings, &parameter, &index)
			&& parameter.FindString(MDSU_VALUES, &value) == B_OK) {
		if(get_boolean_value(value, false))
			fDoesDialOnDemand = true;
		
		parameter.AddBool(MDSU_VALID, true);
		fSettings->ReplaceMessage(MDSU_PARAMETERS, index, &parameter);
	}
	
	index = 0;
	if(FindMessageParameter(PPP_ASK_BEFORE_DIALING_KEY, *fSettings, &parameter, &index)
			&& parameter.FindString(MDSU_VALUES, &value) == B_OK) {
		if(get_boolean_value(value, false))
			fAskBeforeDialing = true;
		
		parameter.AddBool(MDSU_VALID, true);
		fSettings->ReplaceMessage(MDSU_PARAMETERS, index, &parameter);
	}
	
	index = 0;
	if(FindMessageParameter(PPP_AUTO_REDIAL_KEY, *fSettings, &parameter, &index)
			&& parameter.FindString(MDSU_VALUES, &value) == B_OK) {
		if(get_boolean_value(value, false))
			fDoesAutoRedial = true;
		
		parameter.AddBool(MDSU_VALID, true);
		fSettings->ReplaceMessage(MDSU_PARAMETERS, index, &parameter);
	}
	
	if(fConnectionOptionsView)
		fConnectionOptionsView->Reload();
			// reload new settings
	
	return true;
}
Esempio n. 3
0
static int vscode_parse_launch_request(json_value *js, ProtocolMessage *msg,
                                       int msgtype, FILE *log) {
  json_value *args = get_object_value(js, "arguments", log);
  if (args == NULL) return VSCODE_UNKNOWN_REQUEST;
  int found = 0;
  msg->u.Request.u.LaunchRequest.noDebug =
      get_boolean_value(args, "noDebug", log, &found);
  msg->u.Request.u.LaunchRequest.stopOnEntry = get_boolean_value(args, "stopOnEntry", log, &found);
  const char *prog = get_string_value(args, "program", log);
  if (prog == NULL) return VSCODE_UNKNOWN_REQUEST;
  strncpy(msg->u.Request.u.LaunchRequest.program, prog, sizeof msg->u.Request.u.LaunchRequest.program);
  msg->u.Request.request_type = msgtype;
  return msgtype;
}
Esempio n. 4
0
bool value_identity_compare(value_t a, value_t b) {
  if (is_same_value(a, b))
    return true;
  cycle_detector_t detector;
  cycle_detector_init_bottom(&detector);
  value_t ptected = value_identity_compare_cycle_protect(a, b, &detector);
  return in_condition_cause(ccCircular, ptected) ? false : get_boolean_value(ptected);
}
Esempio n. 5
0
/**
 * The device is specified from TSV file. 
 * @param r Request_rec is appointed.
 * @param userAgent UserAgent is appointed here,
 * @return The style which corresponds is returned.
 */
static device_table *
s_specified_device_from_tsv(request_rec *r,device_table *spec,const char *user_agent)
{
  if(spec->device_id == NULL){
    return spec;
  }
  
  DBG(r, "REQ[%X] start %s() device_id:[%s]", TO_ADDR(r), __func__,spec->device_id);
  mod_chxj_config      *conf;
  
  conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
  
  if(conf->device_hash == NULL){
    DBG(r, "REQ[%X] end %s()", TO_ADDR(r),__func__);
    return spec;
  }
  char *key = apr_psprintf(r->pool,"%d.%s",spec->provider,spec->device_id);
  
  apr_table_t *ht = apr_hash_get(conf->device_hash,key,APR_HASH_KEY_STRING);
  
  if(ht != NULL){
    DBG(r, "REQ[%X] found ! %s() %s", TO_ADDR(r), __func__,key);
    int i;
    for ( i=0; i< conf->device_keys->nelts; i++){
      const char *k = ((const char**)conf->device_keys->elts)[i];
      char *val = (char *)apr_table_get(ht,k);
      if(val == NULL){
        continue;
      }
      DBG(r, "REQ[%X] start chxj_specified_device_from_tsv() [%s] = [%s]:[%s]",TO_ADDR(r),spec->device_id,k,val);
      if (STRCASEEQ('d','D',"device_name",k)){
        spec->device_name = apr_pstrdup(r->pool,val);
      }
      if (STRCASEEQ('w','W',"width",k)){
        if(chxj_chk_numeric(val) == 0){
          spec->width = chxj_atoi(val);
        }
      }
      else if (STRCASEEQ('h','H',"heigh",k)){
        if(chxj_chk_numeric(val) == 0){
          spec->heigh = chxj_atoi(val);
        }
      }
      else if (STRCASEEQ('h','H',"height",k)){
        if(chxj_chk_numeric(val) == 0){
          spec->heigh = chxj_atoi(val);
        }
      }
      else if (STRCASEEQ('w','W',"wp_width",k)){
        if(chxj_chk_numeric(val) == 0){
          spec->wp_width = chxj_atoi(val);
        }
      }
      else if (STRCASEEQ('w','W',"wp_heigh",k)){
        if(chxj_chk_numeric(val) == 0){
          spec->wp_heigh = chxj_atoi(val);
        }
      }
      else if (STRCASEEQ('w','W',"wp_height",k)){
        if(chxj_chk_numeric(val) == 0){
          spec->wp_heigh = chxj_atoi(val);
        }
      }
      else if (STRCASEEQ('c','C',"cache",k)){
        if(chxj_chk_numeric(val) == 0){
          spec->cache = chxj_atoi(val);
        }
      }
      else if (STRCASEEQ('g','G',"gif",k)){
        int tmp = get_boolean_value(r,val);
        if(tmp > -1 ){
            spec->available_gif = tmp;
        }
      }
      else if (STRCASEEQ('j','J',"jpeg",k)){
        int tmp = get_boolean_value(r,val);
        if(tmp > -1 ){
            spec->available_jpeg = tmp;
        }
      }
      else if (STRCASEEQ('p','P',"png",k)){
        int tmp = get_boolean_value(r,val);
        if(tmp > -1 ){
          spec->available_png = tmp;
        }
      }
      else if (STRCASEEQ('b','B',"bmp2",k)){
        int tmp = get_boolean_value(r,val);
        if(tmp > -1 ){
          spec->available_bmp2 = tmp;
        }
      }
      else if (STRCASEEQ('b','B',"bmp4",k)){
        int tmp = get_boolean_value(r,val);
        if(tmp > -1 ){
          spec->available_bmp4 = tmp;
        }
      }
      else if (STRCASEEQ('c','C',"color",k)){
        if(chxj_chk_numeric(val) == 0){
          spec->color = chxj_atoi(val);
        }
      }
      else if (STRCASEEQ('e','E',"emoji_type",k)){
        spec->emoji_type = apr_pstrdup(r->pool,val);
      }
      else if (STRCASEEQ('h','H',"html_spec_type",k)){
        if (STRCASEEQ('x','X',"xhtml_mobile_1_0",val)) {
          spec->html_spec_type = CHXJ_SPEC_XHtml_Mobile_1_0;
        }
        else if (STRCASEEQ('c','C',"chtml_1_0",val)) {
          spec->html_spec_type = CHXJ_SPEC_Chtml_1_0;
        }
        else if (STRCASEEQ('c','C',"chtml_2_0",val)) {
          spec->html_spec_type = CHXJ_SPEC_Chtml_2_0;
        }
        else if (STRCASEEQ('c','C',"chtml_3_0",val)) {
          spec->html_spec_type = CHXJ_SPEC_Chtml_3_0;
        }
        else if (STRCASEEQ('c','C',"chtml_4_0",val)) {
          spec->html_spec_type = CHXJ_SPEC_Chtml_4_0;
        }
        else if (STRCASEEQ('c','C',"chtml_5_0",val)) {
          spec->html_spec_type = CHXJ_SPEC_Chtml_5_0;
        }
        else if (STRCASEEQ('c','C',"chtml_6_0",val)) {
          spec->html_spec_type = CHXJ_SPEC_Chtml_6_0;
        }
        else if (STRCASEEQ('c','C',"chtml_7_0",val)) {
          spec->html_spec_type = CHXJ_SPEC_Chtml_7_0;
        }
        else if (STRCASEEQ('h','H',"hdml",val)) {
          spec->html_spec_type = CHXJ_SPEC_Hdml;
        }
        else if (STRCASEEQ('i','I',"ixhtml",val)) {
          spec->html_spec_type = CHXJ_SPEC_Chtml_7_0;
        }
        else if (STRCASEEQ('j','J',"jhtml",val)) {
          spec->html_spec_type = CHXJ_SPEC_Jhtml;
        }
        else if (STRCASEEQ('j','J',"jxhtml",val)) {
          spec->html_spec_type = CHXJ_SPEC_Jxhtml;
        }
        else if (STRCASEEQ('i','I',"iphone2",val)) {
          spec->html_spec_type = CHXJ_SPEC_iPhone2;
        }
        else if (STRCASEEQ('i','I',"iphone3",val)) {
          spec->html_spec_type = CHXJ_SPEC_iPhone3;
        }
        else if (STRCASEEQ('i','I',"iphone4",val)) {
          spec->html_spec_type = CHXJ_SPEC_iPhone4;
        }
        else if (STRCASEEQ('a','A',"android_s",val)) {
          spec->html_spec_type = CHXJ_SPEC_softbank_android;
        }
        else if (STRCASEEQ('a','A',"android_a",val)) {
          spec->html_spec_type = CHXJ_SPEC_au_android;
        }
        else if (STRCASEEQ('a','A',"android_d",val)) {
          spec->html_spec_type = CHXJ_SPEC_docomo_android;
        }
        else if (STRCASEEQ('a','A',"android",val)) {
          spec->html_spec_type = CHXJ_SPEC_android;
        }
      }
      else if (STRCASEEQ('o','O',"output_encoding",k)){
          spec->output_encoding = apr_pstrdup(r->pool,val);
      }
    }
  }
  
  DBG(r, "REQ[%X] end %s() [%d]",TO_ADDR(r),__func__,spec->provider);
  return spec;
}