Esempio n. 1
0
void config_init()
{
	FILE *configfile;
	char *str;
    struct group_of_users *grp = NULL;
    struct user *usr = NULL;
    config_global.options = NULL;
    config_global.directories = NULL;
	if (!configpath)
		return;
	configfile = fopen(configpath, "r");
	if (!configfile) {
		control_printf(SL_FAILURE, "421 Unable to open configuration file.");
		exit(1);
	}
	while ((str = config_read_line(configfile))) {
		if (strchr(str, '{')) {
            replace(str, " {", "{");
            replace(str, "{ ", "{");
            replace(str, " }", "}");
            replace(str, "} ", "}");
            if (!strcasecmp(str, "global{\n")) {
                create_options(configfile, &(config_global.options), &(config_global.directories));
            } else if (strstr(str, "user ") == str) {
                if (usr) {
                    usr = usr->next = malloc(sizeof(struct user));
                } else {
                    config_users = usr = malloc(sizeof(struct user));
                }
                usr->name = strdup(str + 5);
                *strchr(usr->name, '{') = 0;
                create_options(configfile, &(usr->options), &(usr->directories));
            } else if (strstr(str, "group ") == str) {
                if (grp) {
                    grp = grp->next = malloc(sizeof(struct group_of_users));
                } else {
                    config_groups = grp = malloc(sizeof(struct group_of_users));
                }
                cutto(str, 6);
                *strchr(str, '{') = 0;
                grp->users = NULL;
                grp->next = NULL;
                grp->temp_members = strdup(str);
                create_options(configfile, &(grp->options), &(grp->directories));
            }
		}
	}
	fclose(configfile);
}
Esempio n. 2
0
void create_options(FILE *configfile, struct bftpd_option **options, struct directory **directories)
{
    char *str;
    struct bftpd_option *opt = NULL;
    struct directory *dir = NULL;
	str = config_read_line(configfile);
	while (!strchr(str, '}')) {
  		if (str[0] != '\n') {
            if ((strstr(str, "directory")) && (strchr(str, '{')) && (directories)) {
                char *tmp;
                if (dir) {
                    dir = dir->next = malloc(sizeof(struct directory));
                } else {
                    *directories = dir = malloc(sizeof(struct directory));
                }
                tmp = strchr(str, '"') + 1;
                *strchr(tmp, '"') = 0;
                dir->path = strdup(tmp);
                create_options(configfile, &(dir->options), NULL);
            } else {
       			if (opt) {
       				opt = opt->next = malloc(sizeof(struct bftpd_option));
       			} else {
       				*options = opt = malloc(sizeof(struct bftpd_option));
       			}
       			opt->name = (char *) malloc(strlen(str));
       			opt->value = (char *) malloc(strlen(str));
       			sscanf(str, "%[^=]=\"%[^\n\"]", opt->name, opt->value);
            }
   		}
		str = config_read_line(configfile);
	}
}
Esempio n. 3
0
File: gdal.cpp Progetto: rundel/sfr
// [[Rcpp::export]]
Rcpp::List CPL_wrap_dateline(Rcpp::List sfc, Rcpp::CharacterVector opt, bool quiet = true) {

	std::vector <char *> options = create_options(opt, quiet);
	std::vector<OGRGeometry *> g = ogr_from_sfc(sfc, NULL);
	std::vector<OGRGeometry *> ret(g.size());
	for (size_t i = 0; i < g.size(); i++) {
		ret[i] = OGRGeometryFactory::transformWithOptions(g[i], NULL, options.data());
		OGRGeometryFactory::destroyGeometry(g[i]);
	}
	return sfc_from_ogr(ret, true); // destroys ret;
}
Esempio n. 4
0
void create_options(FILE *configfile, struct bftpd_option **options, struct directory **directories)
{
    char *str;
    struct bftpd_option *opt = NULL;
    struct directory *dir = NULL;

	str = config_read_line(configfile);
        if (! str)    /* no data from the file */
           return;
	while (!strchr(str, '}')) {
  		if (str[0] != '\n') {
            if ((strstr(str, "directory")) && (strchr(str, '{')) && (directories)) {
                char *tmp;
                if (dir) {
                    dir = dir->next = malloc(sizeof(struct directory));
                } else {
                    *directories = dir = malloc(sizeof(struct directory));
                }
                /* avoid memory bug */
                if (! dir) return;

                /* tmp = strchr(str, '"') + 1; */
                tmp = strchr(str, '"');
                if (tmp)
                {
                   tmp++;
                   *strchr(tmp, '"') = 0;
                   dir->path = strdup(tmp);
                }
                if (! dir->path) 
                   dir->path = "";
                create_options(configfile, &(dir->options), NULL);
            } else {
       			if (opt) {
       				opt = opt->next = malloc(sizeof(struct bftpd_option));
       			} else {
       				*options = opt = malloc(sizeof(struct bftpd_option));
       			}
                        /* bail out on memory error */
                        if (! opt)
                           return;

       			opt->name = (char *) malloc( strlen(str) + 2 );
       			// opt->value = (char *) malloc(strlen(str));
                        opt->value = (char *) malloc( strlen(str) + 256);
       			sscanf(str, "%[^=]=\"%[^\n\"]", opt->name, opt->value);
            }
   		}
		str = config_read_line(configfile);
                if (! str)    /* avoid segfault */
                   return;
	}
}
Esempio n. 5
0
reforge_plot_t::reforge_plot_t( sim_t* s )
  : sim( s ),
    current_reforge_sim( nullptr ),
    reforge_plot_step( 20 ),
    reforge_plot_amount( 200 ),
    reforge_plot_iterations( -1 ),
    reforge_plot_target_error( 0 ),
    reforge_plot_debug( 0 ),
    current_stat_combo( 0 ),
    num_stat_combos( 0 )
{
  create_options();
}
Esempio n. 6
0
plot_t::plot_t( sim_t* s ) :
  sim( s ),
  dps_plot_step( 20.0 ),
  dps_plot_points( 20 ),
  dps_plot_iterations ( -1 ),
  dps_plot_debug( 0 ),
  current_plot_stat( 0 ),
  num_plot_stats( 0 ),
  remaining_plot_stats( 0 ),
  remaining_plot_points( 0 ),
  dps_plot_positive( 0 )
{
  create_options();
}
Esempio n. 7
0
scaling_t::scaling_t( sim_t* s ) :
  sim( s ), baseline_sim( 0 ), ref_sim( 0 ), delta_sim( 0 ), ref_sim2( 0 ),
  delta_sim2( 0 ),
  scale_stat( STAT_NONE ),
  scale_value( 0 ),
  scale_delta_multiplier( 1.0 ),
  calculate_scale_factors( 0 ),
  center_scale_delta( 0 ),
  positive_scale_delta( 0 ),
  scale_lag( 0 ),
  scale_factor_noise( 0.10 ),
  normalize_scale_factors( 0 ),
  debug_scale_factors( 0 ),
  current_scaling_stat( STAT_NONE ),
  num_scaling_stats( 0 ),
  remaining_scaling_stats( 0 ),
  scale_over(), scale_over_player()
{
  create_options();
}
Esempio n. 8
0
SANE_Status sane_init(SANE_Int* version_code, SANE_Auth_Callback authorize) {
    if (is_initialized) {
        return SANE_STATUS_INVAL;
    }
    SANE_Device *sane_device = NULL;
    SANE_Virtual_Device* virtual_device = NULL;
    SANE_Virtual_Device* previous_virtual_device = NULL;
    *version_code = SANE_VERSION_CODE(MAJOR, MINOR, BUILD);
    sane_device_list = malloc((DEVICE_COUNT + 1) * sizeof(sane_device));
    SANE_Int i;
    for (i = 0; i < DEVICE_COUNT; i++) {
        virtual_device = malloc(sizeof(*virtual_device));
        virtual_device->next = NULL;
        if (i == 0) {
            first_virtual_device = virtual_device;
        } else {
            previous_virtual_device->next = virtual_device;
        }
        previous_virtual_device = virtual_device;
        if (i == 0) {
            virtual_device->device.name = "Scanner 1";
        } else {
            virtual_device->device.name = "Scanner 2";
        }
        virtual_device->device.vendor = "SavvyArk";
        virtual_device->device.model = "Mock Scanner";
        virtual_device->device.type = "Virtual";
        virtual_device->open = SANE_FALSE;
        virtual_device->scanning = SANE_FALSE;
        virtual_device->cancelled = SANE_FALSE;
        virtual_device->pixels_per_line = 0;
        virtual_device->bytes_per_line = 0;
        virtual_device->eof = SANE_FALSE;
        virtual_device->page = 0;
        create_options(virtual_device);
        sane_device_list[i] = &virtual_device->device;
    }
    sane_device_list[i] = NULL;
    is_initialized = SANE_TRUE;
    return SANE_STATUS_GOOD;
}
Esempio n. 9
0
int main(int argc,char ** argv){
if(al_init()<0){ //fonction d'initialisation
    fprintf(stderr,"Error at the initialisation of Allegro");
    return -1;
  }

  if(!al_init_image_addon() ) {
    printf("addon Error");
    return 0;
    }

  options=create_options();
  load_options(options,"Options.txt");
  

  screen=create_screen(options);

  control=create_control(screen);

  ALLEGRO_BITMAP * bg_picture=NULL;
  bg_picture = al_load_bitmap("./Ressources/Pictures/test.png");


  ALLEGRO_BITMAP * image_titre_d=NULL;
  image_titre_d =al_load_bitmap("./Ressources/Pictures/play_d.png");
  ALLEGRO_BITMAP * image_titre_s=NULL;
  image_titre_s=al_load_bitmap("./Ressources/Pictures/play_s.png");
/** DEBUT 
  ALLEGRO_BITMAP * image_credit_d=NULL;
  image_credit_d =al_load_bitmap("./ressource/image/credit_d.png");
  ALLEGRO_BITMAP * image_credit_s=NULL;
  image_credit_s=al_load_bitmap("./ressource/image/credit_s.png");
  ALLEGRO_BITMAP * image_quitter_d=NULL;
  image_quitter_d =al_load_bitmap("./ressource/image/quitter_d.png");
  ALLEGRO_BITMAP * image_quitter_s=NULL;
  image_quitter_s=al_load_bitmap("./ressource/image/quitter_s.png");
*/
  if (!bg_picture || !image_titre_d || !image_titre_s){
    printf("bug image\n");
  }


  struct Title *titles=malloc(sizeof(struct Title)*1);
  struct Menu * menu=create_menu(bg_picture,titles,create_column_position(1,200,300,300),1);
  //struct Control* control=creer_control(ecran);
  /** DEBUT
  void (*p)(void);
  void jouer(){
    partie = creer_partie();
    lancer_jeu(partie);}
  void credits(){
    ALLEGRO_BITMAP * image_credits=NULL;
    image_credits = al_load_bitmap("./ressource/image/credits.png");
    al_draw_bitmap(image_credits,0,0,0);
    al_flip_display();
    al_rest(5.0);
  }
  void quitter(){quitter_jeu(partie);}
  
  
  p=jouer;
  titres[0]=*creer_titre(image_titre_s,image_titre_d,*p);
  p=credits;
  titres[1]=*creer_titre(image_credit_s,image_credit_d,*p);
  p=quitter;
  titres[2]=*creer_titre(image_quitter_s,image_quitter_d,*p);
*/
  void (*p)(void);
  void f(){control_menu(menu,control);}