Пример #1
0
void
chmsee_save_config(ChmSee *self)
{
        FILE *file;
        gchar *path;

        path = g_build_filename(selfp->home, "config", NULL);

        file = fopen(path, "w");

        if (!file) {
                g_print("Faild to open chmsee config: %s", path);
                return;
        }

        save_option(file, "LANG", g_strdup_printf("%d", selfp->lang));
        save_option(file, "LAST_DIR", selfp->last_dir);
        save_option(file, "POS_X", g_strdup_printf("%d", selfp->pos_x));
        save_option(file, "POS_Y", g_strdup_printf("%d", selfp->pos_y));
        save_option(file, "WIDTH", g_strdup_printf("%d", selfp->width));
        save_option(file, "HEIGHT", g_strdup_printf("%d", selfp->height));
        save_option(file, "HPANED_POSTION", g_strdup_printf("%d", chmsee_get_hpaned_position(self)));
        save_option(file, "FULLSCREEN", selfp->fullscreen ? "true" : "false" );

        fclose(file);
        g_free(path);
}
Пример #2
0
void
save_fileinfo(ChmFile *book)
{
  FILE *fd;
  gchar *path;

  path = g_build_filename(book->dir, CHMSEE_BOOKINFO_FILE, NULL);

  g_debug("save bookinfo path = %s", path);

  fd = fopen(path, "w");

  if (!fd) {
    g_print("Faild to open bookinfo file: %s", path);
  } else {
    save_option(fd, "hhc", book->hhc);
    save_option(fd, "hhk", book->hhk);
    save_option(fd, "home", book->home);
    save_option(fd, "title", book->title);
    save_option(fd, "encoding", book->encoding);
    save_option(fd, "variable_font", book->variable_font);
    save_option(fd, "fixed_font", book->fixed_font);

    fclose(fd);
  }
  g_free(path);
}
Пример #3
0
static int		args(
	t_arg_parser p[1], unsigned int opt[1], t_ftvector paths[1])
{
	enum e_arg		a;
	enum e_arg		expect;

	expect = FTARG_NONE;
	while ((a = ft_arg_next(p, expect)) != FTARG_NONE)
	{
		if (a == FTARG_OPTION)
		{
			if (save_option(opt, p->c))
				return (1);
		}
		else if (a == FTARG_STRING)
		{
			if (ftv_push_back(paths, &p->s))
				return (ERRORNO("ftv_push_back"));
			expect = FTARG_STRING;
		}
	}
	return (0);
}
Пример #4
0
int check_arguments( struct_arg_options arg_options, char* text ){

    /* On enregistre l'ID par défaut.*/

    if ( ( strlen( ID ) == ( LENGTH_ID - 1 ) ) && ( atoi( ID ) == 1 ) )
    	strcpy( options.id, ID );
    else{
    	printf( "Bad value of ID in check_arguments.\n" );
    	return EXIT_FAILURE;
    }

    /* Check each display option */

    if ( check_option_page( arg_options.page ) != 0 )
    	return EXIT_FAILURE;

    if ( check_option_lead_cmd( arg_options.lead_cmd ) != 0 )
    	return EXIT_FAILURE;

    if ( check_option_display_meth( arg_options.display_meth ) !=0 )
    	return EXIT_FAILURE;

    if ( check_option_wait_time( arg_options.wait_time ) != 0 )
    	return EXIT_FAILURE;

    if ( check_option_lag_cmd( arg_options.lag_cmd ) != 0 )
    	return EXIT_FAILURE;


    /* Check priority and save it */

    if ( ( arg_options.priority != '0' ) && ( arg_options.priority != '1' ) ){
   	 printf("[!!]ERROR the option 'priority' is not correct.\n");
   	 return EXIT_FAILURE;
    }


    /* Save options to be written in the framework */

    if ( save_option( options.page, arg_options.page ) != 0 )
        	return EXIT_FAILURE;

     if ( save_option( options.lead_cmd, arg_options.lead_cmd ) != 0 )
     	return EXIT_FAILURE;

     if ( save_option( options.display_meth, arg_options.display_meth ) != 0 )
     	return EXIT_FAILURE;

     if ( save_option( options.wait_time, arg_options.wait_time ) != 0 )
     	return EXIT_FAILURE;

     if ( save_option( options.lag_cmd, arg_options.lag_cmd ) != 0 )
     	return EXIT_FAILURE;

     options.priority[0] = arg_options.priority;

    /* Check test message doesn't have any non-supported characters, or replace them */
    if ( check_text( text ) != 0 )
    	return EXIT_FAILURE;

	return EXIT_SUCCESS;
}