예제 #1
0
파일: ebs_value.c 프로젝트: tjordanchat/eag
int load_value (FILE *f, value *v, string *lnames)
{ value nv;
  int tag;
  if (!load_int (f, &tag)) return (0);
  nv = new_value (tag);
  nv -> dptr = (void *) lnames;
  switch (tag)
    { case string_value:
	if (!load_string (f, &nv -> u.str)) return (0);
	break;
      case integer_value:
	if (!load_int (f, &nv -> u.inum)) return (0);
	break;
      case real_value:
	if (!load_real(f, &nv -> u.rnum)) return (0);
	break;
      case tuple_value:
	if (!load_value_list (f, &nv -> u.tuple, lnames)) return (0);
	break;
      case small_lattice_value:
	if (!load_int (f, &nv -> u.slat)) return (0);
	break;
      case large_lattice_value:
	if (!load_int_list (f, &nv -> u.elat)) return (0);
	break;
      default:
	bad_tag (tag, "load_value");
    };
  *v = nv;
  return (1);
};
예제 #2
0
파일: script.c 프로젝트: kasicass/frustum
static int load_land(scene_t *scene,FILE *file,char *path,int texture_mode) {
    char buffer[128];
    land_config_t config;
    memset(&config,0,sizeof(land_config_t));
    config.num_base = 1;
    config.num_detail = 1;
    config.texture_mode = texture_mode;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"land")) load_name(file,path,config.heightmap);
        else if(!strcmp(buffer,"step")) config.step = load_float(file);
        else if(!strcmp(buffer,"altitude")) config.altitude = load_float(file);
        else if(!strcmp(buffer,"lod")) config.lod = load_float(file);
        else if(!strcmp(buffer,"ambient")) load_color(file,config.ambient);
        else if(!strcmp(buffer,"diffuse")) load_color(file,config.diffuse);
        else if(!strcmp(buffer,"specular")) load_color(file,config.specular);
        else if(!strcmp(buffer,"base")) load_name(file,path,config.base);
        else if(!strcmp(buffer,"num_base")) config.num_base = load_int(file);
        else if(!strcmp(buffer,"detail")) load_name(file,path,config.detail);
        else if(!strcmp(buffer,"num_detail")) config.num_detail = load_int(file);
        else if(!strcmp(buffer,"}")) {
            scene->land = land_create(&config);
            break;
        } else return 0;
    }
    if(!scene->land) return 0;
    return 1;
}
예제 #3
0
/*
  Load material parameters

{
  name = 
  type = MATERIAL_PARAMS
}
*/
void generator_mesh::load_section_material_params(DATA_FILE_SECTION *p_section)
{
  DATA_FILE_SECTION *p_line = p_section->section_child_get();
  if(!p_line)
    return;
    
  do {
    if(p_line->is_line()) {
      load_int(material_desc.transparent, "transparent");
      load_int(material_desc.double_side, "double_side");
    }
  } while((p_line = p_line->section_next()));
}
예제 #4
0
파일: setup.c 프로젝트: malikcjm/mc-nt
void panel_load_setup (WPanel *panel, char *section)
{
    int i;
    char buffer [40];
    
    panel->reverse = load_int (section, "reverse", 0);
    panel->case_sensitive = load_int (section, "case_sensitive", OS_SORT_CASE_SENSITIVE_DEFAULT);
    
    /* Load sort order */
    load_string (section, "sort_order", "name", buffer, sizeof (buffer));
    panel->sort_type = (sortfn *) sort_name;
    for (i = 0; sort_names [i].key; i++)
	if (strcasecmp (sort_names [i].key, buffer) == 0){
	    panel->sort_type = sort_names [i].sort_type;
	    break;
	}

    /* Load the listing mode */
    load_string (section, PORT_LIST_MODE_NAME, PORT_LIST_MODE_DEFAULT, buffer, sizeof (buffer));
    panel->list_type = list_full;
    for (i = 0; list_types [i].key; i++)
	if (strcasecmp (list_types [i].key, buffer) == 0){
	    panel->list_type = list_types [i].list_type;
	    break;
	}
#ifndef PORT_HAS_ICON_VIEW
    if (panel->list_type == list_icons)
        panel->list_type = list_full;
#endif
    /* User formats */
    if (panel->user_format){
	free (panel->user_format);
	panel->user_format = 0;
    }
    panel->user_format = strdup (get_profile_string (section, "user_format",
						     DEFAULT_USER_FORMAT,
						     profile_name));
    for (i = 0; i < LIST_TYPES; i++){
        if (panel->user_status_format [i])
	    free (panel->user_status_format [i]);
	sprintf (buffer, "user_status%d", i);
	panel->user_status_format [i] =
	    strdup (get_profile_string (section, buffer,
			DEFAULT_USER_FORMAT, profile_name));
    }
    
    panel->user_mini_status =
	load_int (section, "user_mini_status", 0);

}
예제 #5
0
/*
  Load texture target
{
  name = 
  type = TEXTURE_PARAMS

  texture_size_x = 512
  texture_size_y = 512
}
*/
void generator_mesh::load_section_texture_params(DATA_FILE_SECTION *p_section)
{
  DATA_FILE_SECTION *p_line = p_section->section_child_get();
  if(!p_line)
    return;
    
  do {
    if(p_line->is_line()) {
      load_vect2di(texture_desc.texture_size, "texture_size");
      load_int(texture_desc.texture_height, "texture_height");
      load_rgbaf(texture_desc.texture_background_color, "background_color");
      load_int(texture_desc.texture_alpha, "texture_alpha");
    }
  } while((p_line = p_line->section_next()));
}
예제 #6
0
파일: minipro.c 프로젝트: 960/minipro
/* Model-specific ID, e.g. AVR Device ID (not longer than 4 bytes) */
int minipro_get_chip_id(minipro_handle_t *handle) {
	msg_init(msg, MP_GET_CHIP_ID, handle->device, handle->icsp);
	msg_send(handle, msg, 8);
	msg_recv(handle, msg, 5 + handle->device->chip_id_bytes_count);

	return(load_int(&(msg[2]), handle->device->chip_id_bytes_count, MP_BIG_ENDIAN));
}
예제 #7
0
파일: minipro.c 프로젝트: 960/minipro
void minipro_get_system_info(minipro_handle_t *handle, minipro_system_info_t *out) {
	unsigned char buf[40];
	memset(msg, 0x0, 5);
	msg[0] = MP_GET_SYSTEM_INFO;
	msg_send(handle, msg, 5);
	msg_recv(handle, buf, 40);

	// Protocol version
	switch(out->protocol = buf[1]) {
		case 1:
		case 2:
			break;
		default:
			ERROR("Protocol version error");
	}

	// Model
	switch(out->protocol = buf[6]) {
		case MP_TL866A:
			out->model_str = "TL866A";
			break;
		case MP_TL866CS:
			out->model_str = "TL866CS";
			break;
		default:
			ERROR("Unknown device");
	}

	// Firmware
	out->firmware = load_int(&(buf[4]), 2, MP_LITTLE_ENDIAN);
	if(out->firmware < MP_FIRMWARE_VERSION) {
		fprintf(stderr, "Warning: firmware is too old\n");
	}
	sprintf(out->firmware_str, "%d.%d.%d", buf[39], buf[4], buf[5]);
}
예제 #8
0
파일: script.c 프로젝트: kasicass/frustum
static int load_sky_sun(scene_t *scene,FILE *file,char *path,int texture_mode) {
    char buffer[128],pathname[256];
    float length = 0;
    sky_sun_config_t config;
    memset(&config,0,sizeof(sky_sun_config_t));
    config.texture_mode = texture_mode;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"pos")) load_pos(file,config.pos);
        else if(!strcmp(buffer,"color")) load_color(file,config.color);
        else if(!strcmp(buffer,"num_flare")) config.num_flare = load_int(file);
        else if(!strcmp(buffer,"flare")) load_sky_sun_flare(&config,file,path);
        else if(!strcmp(buffer,"length")) length = load_float(file);
        else if(!strcmp(buffer,"path")) {
            load_name(file,path,pathname);
            if(length <= scene->end - scene->start)
                scene->pathsun = spline_close_load(pathname,length,0,0,0);
            else scene->pathsun = spline_load(pathname,length,0,0,0);
            if(!scene->pathsun) return 0;
        } else if(!strcmp(buffer,"}")) {
            scene->sun = sky_sun_load(&config);
            break;
        } else return 0;
    }
    if(!scene->sun) return 0;
    return 1;
}
예제 #9
0
파일: config.c 프로젝트: mrzzzrm/mooboy
static int config_load(const char *path) {
    printf("Loading config from '%s'\n", path);

    file = fopen(path, "r");
    if(file == NULL) {
        return 0;
    }

    parse();
    fclose(file);

    int v;
    for(v = 0; v < sizeof(values)/sizeof(*values); v++) {
         *values[v].ptr = load_int(values[v].name, values[v].default_val);
    }

    clear();

    if(sys.scalingmode < 0 || sys.scalingmode >= sys.num_scalingmodes) {
        moo_errorf("No such scalingmode %i, please delete config or insert a valid value", sys.scalingmode);
        sys_set_scalingmode(0);
        return 0;
    }
    sys_set_scalingmode(sys.scalingmode);
    speed_set_factor(speed.factor);

    return 1;
}
예제 #10
0
파일: common.c 프로젝트: tari3x/csec-modex
void append_zero(const unsigned char * buf)
{
  load_all(buf, "");
  load_int(0, true, sizeof(char), "");
  // load_str("00");
  Append();
  store_all(buf);
}
예제 #11
0
파일: Decoder.cpp 프로젝트: bcajes/hail
int StreamInputBlockBuffer::read_block(char * buf) {
  auto r = input_stream_->read(len_buf_, 4);
  if (r == -1) {
    return -1;
  }
  int len = load_int(len_buf_);
  return input_stream_->read(buf, len);
}
예제 #12
0
/*
{
  name = ***
  type = GENERATOR_MESH_CONFIG
}
*/
void generator_mesh::load_section_generator_config(DATA_FILE_SECTION *p_section)
{
  DATA_FILE_SECTION *p_line = p_section->section_child_get();
  if(!p_line)
    return;
  
  // Set name of this generator
  name_set(p_section->name_get());
  
  int modificator_index = -1;
  int target_index = -1;
  do {
    if(p_line->is_line()) {
      
      if(p_line->match_name("modificator")) {
        modificator_index++;
        target_index = -1;
        GENERATOR_MESH_MODIFICATOR_CONFIG *p_modificator = config.modificator_ref(modificator_index);
        strncpy(p_modificator->modificator_name, p_line->line_value_string_get(), MAX_NAME);
        p_line->line_mark_loaded();        
        continue;
      }
      else if(modificator_index >= 0) {        
        GENERATOR_MESH_MODIFICATOR_CONFIG *p_modificator = config.modificator_ref(modificator_index);

        // modificator target - for unique targets (TEXTURE/MESH)
        if(p_line->match_name("modificator_target")) {
          target_index++;
          GENERATOR_MESH_MODIFICATOR_TARGET_CONFIG *p_target = p_modificator->target_config_ref(target_index);
          p_target->target_type = modificator_target_translate(p_line->line_value_string_get());
          if(p_target->target_type == MODIFICATOR_TARGET_NONE) {            
            ppset(p_line->source_file_get(), p_line->source_line_get());
            pperror(TRUE, "'%s' is not a valid modificator target!",p_line->line_value_string_get());
            ppclear();
          }
          p_line->line_mark_loaded();
          continue;
        }
        else {
          GENERATOR_MESH_MODIFICATOR_TARGET_CONFIG *p_target = p_modificator->target_config_ref(target_index);
          
          // For other targets (BITMAP/HEIGHTMAP/AUX)
          if(p_line->match_name("modificator_target_name")) {
            strncpy(p_target->target_name, p_line->line_value_string_get(), MAX_NAME);
            p_line->line_mark_loaded();
            continue;
          }
      
          // Load repeat
          load_int(p_target->repeat,"modificator_repeat");
                    
          // Load mask
          p_target->mask.load_line(p_line, generator_get());
        }
      }
    }
  } while((p_line = p_line->section_next()));
}
예제 #13
0
파일: setup.c 프로젝트: malikcjm/mc-nt
static void load_layout (char *profile_name)
{
    int i;
    
    for (i = 0; layout [i].opt_name; i++)
	*layout [i].opt_addr =
	    load_int ("Layout", layout [i].opt_name,
				  *layout [i].opt_addr);
}
예제 #14
0
char *load_string( FILE *fp )
{ 
  int len = load_int(fp);
  if ( len < 0 || isnan(len) || isinf(len) ) 
    die ("load_string: improper number of strings to load: %d\n",len);
  char *string = (char *) calloc (len+2, sizeof(char));
  fread_safe(string, sizeof(char), len + 1, fp);
  return string;
}
예제 #15
0
파일: minipro.c 프로젝트: 960/minipro
int minipro_get_status(minipro_handle_t *handle) {
	unsigned char buf[32];
	msg_init(msg, MP_REQUEST_STATUS1_MSG2, handle->device, handle->icsp);
	msg_send(handle, msg, 5);
	msg_recv(handle, buf, 32);

	if(buf[9] != 0) {
		ERROR("Overcurrency protection");
	}

	return(load_int(buf, 2, MP_LITTLE_ENDIAN));
}
예제 #16
0
파일: ebs_value.c 프로젝트: tjordanchat/eag
int load_value_list (FILE *f, value_list *vl, string *lnames)
{ int ix, size;
  value_list nvl;
  if (!load_int (f, &size)) return (0);
  nvl = new_value_list (size);
  nvl -> size = size;
  nvl -> room = size;
  for (ix = 0; ix < size; ix++)
    if (!load_value (f, &nvl -> array[ix], lnames)) return (0);
  *vl = nvl;
  return (1);
};
예제 #17
0
void master_conf::load(const char* path)
{
	if (cfg_loaded_)
		return;
	if (path)
		cfg_ = acl_xinetd_cfg_load(path);
	cfg_loaded_ = true;

	load_bool();
	load_int();
	load_int64();
	load_str();
}
예제 #18
0
/*
  Load geometry target

{
  name = ***
  type = MESH_PARAMS

  mesh_start_x = 0
  mesh_start_y = 0
  mesh_start_z = 0

  mesh_size_x = 50
  mesh_size_y = 0
  mesh_size_z = 50

  mesh_diff_x = 1
  mesh_diff_y = 0
  mesh_diff_z = 1
}
*/
void generator_mesh::load_section_mesh_params(DATA_FILE_SECTION *p_section)
{
  DATA_FILE_SECTION *p_line = p_section->section_child_get();
  if(!p_line)
    return;
    
  VECT    start(0);
  bool    start_active = FALSE;
  VECT    diff(0);
  bool    diff_active = FALSE;
  VECT3DI size(0);
  bool    size_active = FALSE;
  
  do {
    if(p_line->is_line()) {
      load_mesh_type(geometry_desc.type,"mesh_type");
      
      load_vect3df_active(start,"start");
      load_vect3df_active(diff,"diff");
      load_vect3di_active(size,"size");
      
      load_interval_int(geometry_desc.bunch_slice_num,"bunch_slice_num");
      load_interval_int(geometry_desc.bunch_slice_segments,"bunch_slice_segments");
      
      load_interval_float(geometry_desc.bunch_slice_x_offset,"bunch_slice_x_offset");
      load_interval_float(geometry_desc.bunch_slice_z_offset,"bunch_slice_z_offset");
      
      load_interval_float(geometry_desc.bunch_slice_width_start,"bunch_slice_width_start");
      load_interval_float(geometry_desc.bunch_slice_width_end,"bunch_slice_width_end");

      load_interval_float(geometry_desc.bunch_slice_height_start,"bunch_slice_height_start");
      load_interval_float(geometry_desc.bunch_slice_height_end,"bunch_slice_height_end");
      
      load_interval_angle(geometry_desc.bunch_slice_falling,"bunch_slice_falling");
      load_interval_angle(geometry_desc.bunch_segment_falling,"bunch_segment_falling");
      
      load_int(geometry_desc.bunch_slice_rotation_incemental,"bunch_slice_rotation_incemental");
      load_interval_angle(geometry_desc.bunch_slice_rotation_range,"bunch_slice_rotation_range");
      load_interval_angle(geometry_desc.bunch_slice_rotation_step,"bunch_slice_rotation_step");
    }
  } while((p_line = p_line->section_next()));
  
  if(start_active)
    geometry_desc.start = start;
  if(diff_active)
    geometry_desc.diff = diff;
  if(size_active)
    geometry_desc.size = size;
}
예제 #19
0
파일: script.c 프로젝트: kasicass/frustum
static int load_sky_layer(sky_config_t *config,FILE *file,char *path) {
    char buffer[128];
    int layer = 0;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"layer")) layer = load_int(file);
        else if(!strcmp(buffer,"height")) config->height[layer] = load_float(file);
        else if(!strcmp(buffer,"time")) config->time[layer] = load_float(file);
        else if(!strcmp(buffer,"texture")) load_name(file,path,config->texture[layer]);
        else if(!strcmp(buffer,"}")) break;
        else return 0;
    }
    return 1;
}
예제 #20
0
/*
  Load aux target
{
  name = test_aux
  type = AUX_PARAMS

  aux_size.x = 512
  aux_size.y = 512
}
*/
void generator_mesh::load_section_aux_params(DATA_FILE_SECTION *p_section)
{
  TEXTURE_DESCRIPTION aux;
  
  DATA_FILE_SECTION *p_line = p_section->section_child_get();    
  if(p_line) {      
    do {
      if(p_line->is_line()) {
        load_vect2di(aux.texture_size, "aux_size");
        load_int(aux.texture_height, "aux_height");
        load_rgbaf(aux.texture_background_color, "background_color");
        load_int(aux.texture_alpha, "aux_alpha");
      }
    } while((p_line = p_line->section_next()));
  }
  
  MODIFICATOR_TARGET_AUX *p_target =
  (MODIFICATOR_TARGET_AUX *)target_cache.target_get(MODIFICATOR_TARGET_AUX_TYPE,
                                                    p_section->line_name_get());
  p_target->init(aux.texture_size, aux.texture_height);
  
  SURFACE_SW *p_bitmap = p_target->bitmap_get();
  p_bitmap->fill(aux.texture_background_color);
}
예제 #21
0
파일: script.c 프로젝트: kasicass/frustum
static int load_sky_sun_flare(sky_sun_config_t *config,FILE *file,char *path) {
    char buffer[128];
    int flare = 0;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"flare")) flare = load_int(file);
        else if(!strcmp(buffer,"position")) config->position[flare] = load_float(file);
        else if(!strcmp(buffer,"radius")) config->radius[flare] = load_float(file);
        else if(!strcmp(buffer,"opacity")) config->opacity[flare] = load_float(file);
        else if(!strcmp(buffer,"texture")) load_name(file,path,config->texture[flare]);
        else if(!strcmp(buffer,"}")) break;
        else return 0;
    }
    return 1;
}
예제 #22
0
파일: tencode.c 프로젝트: clj/kroc_scons
static tbc_ffi_t *decode_ffi (BYTE *head, const tenc_element_t *ffi_element)
{
	tenc_element_t 	element;
	tenc_str_t	*sym;
	tbc_ffi_t	*ffi	= (tbc_ffi_t *) head;
	BYTE 		*data	= ffi_element->data.bytes;
	unsigned int 	length	= ffi_element->length;

	if (tenc_walk_to_element (data, &length, "libL", &element) < 0)
		return NULL;
	
	ffi->libraries	= decode_strs (element.data.bytes, element.length, "libS");
	data		= element.next;
	
	if (tenc_walk_to_element (data, &length, "symL", &element) < 0)
		return NULL;

	ffi->symbols	= decode_strs (element.data.bytes, element.length, "symS");
	data		= element.next;

	if (tenc_walk_to_element (data, &length, "mapL", &element) < 0)
		return NULL;
	
	ffi->n_symbols	= 0;
	ffi->map 	= (tbc_ffi_entry_t *) (element.data.bytes - (4 + sizeof (WORD)));
	length		= element.length;
	data		= element.data.bytes;
	sym		= ffi->symbols;
	while ((sym != NULL) && (length > 0)) {
		WORD lib_idx;

		if (load_int (&data, &length, "idxI", &lib_idx) < 0)
			return NULL;

		ffi->map[ffi->n_symbols].symbol = sym->str;
		ffi->map[ffi->n_symbols].library = lib_idx;

		ffi->n_symbols++;
		sym = sym->next;
	}
	
	if (sym != NULL)
		return NULL;

	return ffi;
}
예제 #23
0
/*
 * Creates a new GtkWidget of class GtkCList, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 * If the widget needs a special destroy handler, add a signal here.
 */
static GtkWidget *
gb_tclist_new (GbWidgetNewData * data)
{
  GtkWidget *new_widget;
#ifndef GTK_HAVE_FEATURES_1_1_4
  GtkAdjustment *adjustment;
#endif
  gint cols = 0, i;

  if (data->action == GB_LOADING)
    {
      cols = load_int (data->loading_data, Cols);
      if (cols == 0)
	cols = 1;
      new_widget = tclist_new (cols);

      /* GtkCList has problems if the title buttons aren't created. */
      for (i = 0; i < cols; i++)
	{
	  gtk_clist_set_column_widget (GTK_CLIST (new_widget), i,
                                       new_unnamed_label (new_widget));
	  gtk_clist_set_column_width (GTK_CLIST (new_widget), i, 80);
          editor_add_mouse_signals_to_existing (GTK_CLIST (new_widget)->column[i].button);
	}

      /* Connect signals for redrawing. */
      /* The CList doesn't have scrollbars in 1.1.4+. We'll have to do this
	 another way at some point. */
#ifndef GTK_HAVE_FEATURES_1_1_4
      adjustment = gtk_range_get_adjustment (GTK_RANGE (GTK_CLIST (new_widget)->hscrollbar));
      gtk_signal_connect_after (GTK_OBJECT (adjustment), "value_changed",
				(GtkSignalFunc) hadjustment_value_changed,
				new_widget);
      adjustment = gtk_range_get_adjustment (GTK_RANGE (GTK_CLIST (new_widget)->vscrollbar));
      gtk_signal_connect_after (GTK_OBJECT (adjustment), "value_changed",
				(GtkSignalFunc) vadjustment_value_changed,
				new_widget);
#endif
      return new_widget;
    }
  else
    {
      show_tclist_dialog (data);
      return NULL;
    }
}
예제 #24
0
static asn1_error_code
load_count(const void *val, const struct counted_info *counted,
           size_t *count_out)
{
    const void *countptr = (const char *)val + counted->lenoff;

    assert(sizeof(size_t) <= sizeof(uintmax_t));
    if (counted->lensigned) {
        intmax_t xlen = load_int(countptr, counted->lensize);
        if (xlen < 0 || (uintmax_t)xlen > SIZE_MAX)
            return EINVAL;
        *count_out = xlen;
    } else {
        uintmax_t xlen = load_uint(countptr, counted->lensize);
        if ((size_t)xlen != xlen || xlen > SIZE_MAX)
            return EINVAL;
        *count_out = xlen;
    }
    return 0;
}
예제 #25
0
void master_conf::set_cfg_int(master_int_tbl* table)
{
	if (table == NULL || int_cfg_)
		return;

	int  i = 0;
	for (; table[i].name != NULL; i++);
	int_cfg_ = (ACL_CFG_INT_TABLE*) acl_mycalloc(i + 1,
		sizeof(ACL_CFG_INT_TABLE));

	for (i = 0; table[i].name != NULL; i++)
	{
		int_cfg_[i].name = table[i].name;
		int_cfg_[i].defval = table[i].defval;
		int_cfg_[i].target = table[i].target;
		int_cfg_[i].min = table[i].min;
		int_cfg_[i].max = table[i].max;
	}
	int_cfg_[i].name = NULL;
	load_int();
}
예제 #26
0
파일: script.c 프로젝트: kasicass/frustum
static int load_sky(scene_t *scene,FILE *file,char *path,int texture_mode) {
    char buffer[128];
    sky_config_t config;
    memset(&config,0,sizeof(sky_config_t));
    config.texture_mode = texture_mode;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"mesh")) load_name(file,path,config.mesh);
        else if(!strcmp(buffer,"num_layer")) config.num_layer = load_int(file);
        else if(!strcmp(buffer,"target")) config.target = load_float(file);
        else if(!strcmp(buffer,"layer")) load_sky_layer(&config,file,path);
        else if(!strcmp(buffer,"sun")) {
            if(!load_sky_sun(scene,file,path,texture_mode)) return 0;
        } else if(!strcmp(buffer,"}")) {
            scene->sky = sky_load(&config);
            break;
        } else return 0;
    }
    if(!scene->sky) return 0;
    return 1;
}
예제 #27
0
/* Encode a value (contents only, no outer tag) according to a type, and return
 * its encoded tag information. */
static asn1_error_code
encode_atype(asn1buf *buf, const void *val, const struct atype_info *a,
             taginfo *tag_out, size_t *len_out)
{
    asn1_error_code ret;

    if (val == NULL)
        return ASN1_MISSING_FIELD;

    switch (a->type) {
    case atype_fn: {
        const struct fn_info *fn = a->tinfo;
        assert(fn->enc != NULL);
        return fn->enc(buf, val, tag_out, len_out);
    }
    case atype_sequence:
        assert(a->tinfo != NULL);
        ret = encode_sequence(buf, val, a->tinfo, len_out);
        if (ret)
            return ret;
        tag_out->asn1class = UNIVERSAL;
        tag_out->construction = CONSTRUCTED;
        tag_out->tagnum = ASN1_SEQUENCE;
        break;
    case atype_ptr: {
        const struct ptr_info *ptr = a->tinfo;
        assert(ptr->basetype != NULL);
        return encode_atype(buf, LOADPTR(val, ptr), ptr->basetype, tag_out,
                            len_out);
    }
    case atype_offset: {
        const struct offset_info *off = a->tinfo;
        assert(off->basetype != NULL);
        return encode_atype(buf, (const char *)val + off->dataoff,
                            off->basetype, tag_out, len_out);
    }
    case atype_optional: {
        const struct optional_info *opt = a->tinfo;
        assert(opt->is_present != NULL);
        if (opt->is_present(val))
            return encode_atype(buf, val, opt->basetype, tag_out, len_out);
        else
            return ASN1_OMITTED;
    }
    case atype_counted: {
        const struct counted_info *counted = a->tinfo;
        const void *dataptr = (const char *)val + counted->dataoff;
        size_t count;
        assert(counted->basetype != NULL);
        ret = load_count(val, counted, &count);
        if (ret)
            return ret;
        return encode_cntype(buf, dataptr, count, counted->basetype, tag_out,
                             len_out);
    }
    case atype_nullterm_sequence_of:
    case atype_nonempty_nullterm_sequence_of:
        assert(a->tinfo != NULL);
        ret = encode_nullterm_sequence_of(buf, val, a->tinfo,
                                          a->type ==
                                          atype_nullterm_sequence_of,
                                          len_out);
        if (ret)
            return ret;
        tag_out->asn1class = UNIVERSAL;
        tag_out->construction = CONSTRUCTED;
        tag_out->tagnum = ASN1_SEQUENCE;
        break;
    case atype_tagged_thing: {
        const struct tagged_info *tag = a->tinfo;
        ret = encode_atype(buf, val, tag->basetype, tag_out, len_out);
        if (ret)
            return ret;
        if (!tag->implicit) {
            size_t tlen;
            ret = make_tag(buf, tag_out, *len_out, &tlen);
            if (ret)
                return ret;
            *len_out += tlen;
            tag_out->construction = tag->construction;
        }
        tag_out->asn1class = tag->tagtype;
        tag_out->tagnum = tag->tagval;
        break;
    }
    case atype_bool:
        ret = k5_asn1_encode_bool(buf, load_int(val, a->size), len_out);
        if (ret)
            return ret;
        tag_out->asn1class = UNIVERSAL;
        tag_out->construction = PRIMITIVE;
        tag_out->tagnum = ASN1_BOOLEAN;
        break;
    case atype_int:
        ret = k5_asn1_encode_int(buf, load_int(val, a->size), len_out);
        if (ret)
            return ret;
        tag_out->asn1class = UNIVERSAL;
        tag_out->construction = PRIMITIVE;
        tag_out->tagnum = ASN1_INTEGER;
        break;
    case atype_uint:
        ret = k5_asn1_encode_uint(buf, load_uint(val, a->size), len_out);
        if (ret)
            return ret;
        tag_out->asn1class = UNIVERSAL;
        tag_out->construction = PRIMITIVE;
        tag_out->tagnum = ASN1_INTEGER;
        break;
    case atype_int_immediate: {
        const struct immediate_info *imm = a->tinfo;
        ret = k5_asn1_encode_int(buf, imm->val, len_out);
        if (ret)
            return ret;
        tag_out->asn1class = UNIVERSAL;
        tag_out->construction = PRIMITIVE;
        tag_out->tagnum = ASN1_INTEGER;
        break;
    }
    default:
        assert(a->type > atype_min);
        assert(a->type < atype_max);
        abort();
    }

    return 0;
}
예제 #28
0
static unsigned int msg_recv_int(programmer_t *pgm, unsigned int length) {
	unsigned char buf[4];
	msg_recv(pgm, buf, length);
	return load_int(buf, length, MP_LITTLE_ENDIAN);
}