• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ config_init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中config_init函数的典型用法代码示例。如果您正苦于以下问题:C++ config_init函数的具体用法?C++ config_init怎么用?C++ config_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了config_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: session_get_user

// {{{ session_get_user()
int session_get_user(const char *sessid, char *user, size_t len)
{
   struct config_t cfg;
   config_init(&cfg);
   config_setting_t *cs;
   config_setting_t *vs;

   if(!config_read_file(&cfg, OD_SESSION_FILE))
      return -1;

   int i=0;
   for(i=0; ;i++)
   {
      if( !(cs = config_setting_get_elem(cfg.root, i)) )
         break;

      if( !(vs = config_setting_get_member(cs, "sessid")) )
         continue;

      char *session_user = config_setting_name(cs);
      if(!session_user)
         continue;

      const char *res = config_setting_get_string(vs);
      if(res)
         if(strcmp(res, sessid)==0)
         {
            sstrncpy(user, session_user, len);
            config_destroy(&cfg);
            return 0;
         }

   }

   config_destroy(&cfg);
   return -1;
}
开发者ID:evomonza,项目名称:opendomo,代码行数:38,代码来源:session.c


示例2: config_load

int config_load(struct config* conf, const char* filename)
{
	config_init(conf);
	FILE* f=fopen(filename, "r");
	if(!f) return -1;
	int r=1;
	char* line=NULL;
	size_t s=0;
	char header[ITEM_MAXLEN];
	char left[ITEM_MAXLEN];
	char right[ITEM_MAXLEN];
	while((r = getline(&line, &s, f)) != -1)
	{
		int h=sscanf(line, "[%[^\n]", header);
		if(!h)
		{
			h=sscanf(line, "%*[ \t]%[^=]=%[^\n]", left, right);
			if(h==1)
			{
				h=sscanf(line, "%*[ \t]%[^\n]", left);
				if(h==1) config_add(conf, header, left, NULL);
				else return -1;
			}
			else if(h==2) config_add(conf, header, left, right);
			else return -1;
		}
		else
		{
			size_t hlen = strnlen(header, ITEM_MAXLEN)-1;
			if(header[hlen]==']') header[hlen]=0;
			else return -1;
		}
	}
	free(line);
	fclose(f);
	return 0;
}
开发者ID:Detegr,项目名称:HBot,代码行数:37,代码来源:config.c


示例3: main

int
main(int argc, char *argv[])
{
    serverstate_set_event_loop(uv_default_loop());

    config_init();
    listener_init();
    client_init();
    module_init();
    server_init();
    command_init();
    connection_init();

    process_commandline(argv, argc);

    config_load();
    listener_start_listeners();
    module_load_all_modules();
    connection_init_tls();

    uv_run(serverstate_get_event_loop(), UV_RUN_DEFAULT);

    return 0;
}
开发者ID:tony,项目名称:oftc-ircd,代码行数:24,代码来源:main.c


示例4: main

/* main:
 * Entry point. See usage(). */
int main(int argc, char **argv) {
    pthread_t thread;
    struct sigaction sa = {};

    setlocale(LC_ALL, "");

    /* TODO: tidy this up */
    /* read command line options and config file */   
    config_init();
    options_set_defaults();
    options_read_args(argc, argv);
    /* If a config was explicitly specified, whinge if it can't be found */
    read_config(options.config_file, options.config_file_specified);
    options_make();
    
    sa.sa_handler = finish;
    sigaction(SIGINT, &sa, NULL);

    pthread_mutex_init(&tick_mutex, NULL);

    packet_init();

    init_history();

    ui_init();

    pthread_create(&thread, NULL, (void*)&packet_loop, NULL);

    ui_loop();

    //pthread_cancel(thread); // bionic c have no pthread_cancel, by dove

    ui_finish();
    
    return 0;
}
开发者ID:dove0rz,项目名称:iftop-android,代码行数:38,代码来源:iftop.c


示例5: fopen

void Settings::Load()
{
	FILE* fileHnd;

	fileHnd = fopen( "settings.cfg", "rb" );
	if( fileHnd != 0 )
	{
		fclose( fileHnd );

		config_t cfg;
		config_setting_t *setting;

		config_init(&cfg);
		config_read_file( &cfg, "settings.cfg" );

		setting = config_lookup( &cfg, "Graphics" );
		config_setting_lookup_int( setting, "FullScreen", &FullScreen );

		setting = config_lookup( &cfg, "Audio" );
		config_setting_lookup_int( setting, "PlaySFX", &PlaySFX );
		config_setting_lookup_int( setting, "PlayMusic", &PlayMusic );

		setting = config_lookup( &cfg, "Input" );
		config_setting_lookup_int( setting, "keyLeft", (int*)&keyLeft );
		config_setting_lookup_int( setting, "keyRight", (int*)&keyRight );
		config_setting_lookup_int( setting, "keyUp", (int*)&keyUp );
		config_setting_lookup_int( setting, "keyDown", (int*)&keyDown );
		config_setting_lookup_int( setting, "keyFire1", (int*)&keyFire1 );
		config_setting_lookup_int( setting, "keyFire2", (int*)&keyFire2 );
		config_setting_lookup_int( setting, "keyQuit", (int*)&keyQuit );

		config_destroy(&cfg);
	} else {
		Init();
	}
}
开发者ID:pmprog,项目名称:P01,代码行数:36,代码来源:settings.cpp


示例6: config_console

/*
 * this function needs to get enough configured to do a console
 * basically this means start attaching the grfxx's that support 
 * the console. Kinda hacky but it works.
 */
void
config_console(void)
{	
	cfdata_t cf;

	config_init();

	/*
	 * we need mainbus' cfdata.
	 */
	cf = config_rootsearch(NULL, "mainbus", __UNCONST("mainbus"));
	if (cf == NULL)
		panic("no mainbus");

	/*
	 * Note: The order of the 'atari_config_found()' calls is
	 * important! On the Hades, the 'pci-side' of the config does
	 * some setup for the 'grf-side'. This make it possible to use
	 * a PCI card for both wscons and grfabs.
	 */
	atari_config_found(cf, NULL, __UNCONST("pcib")  , NULL);
	atari_config_found(cf, NULL, __UNCONST("isab")  , NULL);
	atari_config_found(cf, NULL, __UNCONST("grfbus"), NULL);
}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:29,代码来源:autoconf.c


示例7: print_colour

int* print_colour()
{
	config_setting_t *color_list, *layout;
	config_t layout_config;
	int color_len, i;
	const char* color_value;
	int* RGB_array;

	config_init(&layout_config);
	if (!config_read_file(&layout_config, "./layout.cfg")) {
        	fprintf(stderr, "%s:%d - %s\n",
           				config_error_file(&layout_config),
            			config_error_line(&layout_config),
            			config_error_text(&layout_config));
        	config_destroy(&layout_config);
        	return NULL;
    	}
	
	color_list = config_lookup(&layout_config, "application.colors");
	color_len = config_setting_length(color_list);
	RGB_array=malloc(sizeof (int)*3*color_len);
	for(i = 0; i < color_len; i++)
	{
		layout = config_setting_get_elem(color_list, i);
		config_setting_lookup_string(layout, "name", &color_value);
		printf(" %i)\t", i+1);
		printf("%s\n", color_value);
		config_setting_lookup_int(layout, "r", &RGB_array[i*3]);
		config_setting_lookup_int(layout, "g", &RGB_array[i*3+1]);
		config_setting_lookup_int(layout, "b", &RGB_array[i*3+2]);
		printf("\tR-G-B: %i-%i-%i\n",RGB_array[i*3],RGB_array[i*3+1],RGB_array[i*3+2]);
	}
	
	config_destroy(&layout_config);
	return RGB_array;
}
开发者ID:ChiaraCaiazza,项目名称:collageMaker,代码行数:36,代码来源:layout.c


示例8: main

int main(int argc, char *argv[])
{
    config_init(argc, argv);

    if (glue_init() != 0)
    {
        iotc_error("glue init failed!");
        return -1;
    }

    if (0 != connection_init())
    {
        iotc_error("socket_init failed!");
        return -1;
    }

    uloop_init();
    uloop_fd_add(&iotc_monitor_uloop_fd, ULOOP_READ);
    uloop_timeout_set(&g_sendDevOnlineTm, 2000);
    uloop_run();
    uloop_done();

    return 0;
}
开发者ID:gjz22cn,项目名称:openwrt,代码行数:24,代码来源:main.c


示例9: config_init

// ----------------------------------------------------------------------------------------
// Sistema Multilinguagem
// ----------------------------------------------------------------------------------------
// read_message("Grupo.SubGrupo.String");
// ----------------------------------------------------------------------------------------
// http://www.hyperrealm.com/libconfig/libconfig_manual.html
// ----------------------------------------------------------------------------------------
char *read_message(const char *param)
{
	static char message[512];
	config_setting_t *str;
	config_t configLang;

	config_init(&configLang);

	if(!config_read_file(&configLang, (!strlen(bra_config.lang_file)?"conf/lang/pt_br.conf":bra_config.lang_file))) {
		ShowError("read_message erro: %s:%d - %s\n", config_error_file(&configLang), config_error_line(&configLang), config_error_text(&configLang));
		config_destroy(&configLang);
		return "";
	}

	if(!(str = config_lookup(&configLang, param))) {
		ShowError("read_message erro: %s\n", param);
		config_destroy(&configLang);
		return "";
	}
	
	strncpy(message, config_setting_get_string(str), sizeof(message));
	config_destroy(&configLang);
	return message;
}
开发者ID:Mateuus,项目名称:brathena-1,代码行数:31,代码来源:lang.c


示例10: main

int
main(int argc, char **argv)
{
    int result;
    static TestUtilsTest tests[] = {
        TU_TEST(test_vfs_free_space, 90),
	TU_END()
    };

    glib_init();
    config_init(0, NULL);
    device_api_init();

    /* TODO: if more tests are added, we'll need a setup/cleanup hook
     * for testutils */
    device_path = setup_vtape_dir();

    result = testutils_run_tests(argc, argv, tests);

    cleanup_vtape_dir(device_path);
    amfree(device_path);

    return result;
}
开发者ID:malclocke,项目名称:amanda,代码行数:24,代码来源:vfs-test.c


示例11: get_defaults

void get_defaults(char *filename, struct udata *ud)
{
	config_t cfg, *cf;
	const char *value;
#if LIBCONFIG_VER_MAJOR == 1
# if LIBCONFIG_VER_MINOR >= 4
	int ival;
# endif
# else
	long ival;
#endif

	if (access(filename, R_OK) == -1) {
		olog(LOG_ERR, "Cannot read defaults from %s: %s", filename, strerror(errno));
		return;
	}

	config_init(cf = &cfg);

	if (!config_read_file(cf, filename)) {
		olog(LOG_ERR, "Syntax error in %s:%d - %s",
			filename,
			config_error_line(cf),
			config_error_text(cf));
		config_destroy(cf);
		exit(2);
	}

	if (config_lookup_string(cf, "OTR_STORAGEDIR", &value) != CONFIG_FALSE)
		strcpy(STORAGEDIR, value);

	if (ud == NULL) {
		/* being invoked by ocat; return */
		return;
	}
#if WITH_MQTT
	if (config_lookup_string(cf, "OTR_HOST", &value) != CONFIG_FALSE) {
		if (ud->hostname) free(ud->hostname);
		ud->hostname = (value) ? strdup(value) : NULL;
	}
	if (config_lookup_int(cf, "OTR_PORT", &ival) != CONFIG_FALSE) {
		ud->port = ival;
	}
	if (config_lookup_string(cf, "OTR_USER", &value) != CONFIG_FALSE) {
		if (ud->username) free(ud->username);
		ud->username = (value) ? strdup(value) : NULL;
	}
	if (config_lookup_string(cf, "OTR_PASS", &value) != CONFIG_FALSE) {
		if (ud->password) free(ud->password);
		ud->password = (value) ? strdup(value) : NULL;
	}
	if (config_lookup_int(cf, "OTR_QOS", &ival) != CONFIG_FALSE) {
		ud->qos = ival;
	}
	if (config_lookup_string(cf, "OTR_CLIENTID", &value) != CONFIG_FALSE) {
		if (ud->clientid) free(ud->clientid);
		ud->clientid = (value) ? strdup(value) : NULL;
	}

	if (config_lookup_string(cf, "OTR_CAFILE", &value) != CONFIG_FALSE) {
		if (ud->cafile) free(ud->cafile);
		ud->cafile = (value) ? strdup(value) : NULL;
	}

	/* Topics is a blank-separated string of words; split and add to JSON array */
	if (config_lookup_string(cf, "OTR_TOPICS", &value) != CONFIG_FALSE) {
		char *parts[40];
		int np, n;
		if (ud->topics) json_delete(ud->topics);

		if ((np = splitter((char *)value, " ", parts)) < 1) {
			olog(LOG_ERR, "Illegal value in OTR_TOPICS");
			exit(2);
		}
		ud->topics = json_mkarray();

		for (n = 0; n < np; n++) {
			json_append_element(ud->topics, json_mkstring(parts[n]));
		}
		splitterfree(parts);
	}
#endif /* WITH_MQTT */

	if (config_lookup_string(cf, "OTR_GEOKEY", &value) != CONFIG_FALSE) {
		if (ud->geokey) free(ud->geokey);
		ud->geokey = (value) ? strdup(value) : NULL;
	}

	if (config_lookup_int(cf, "OTR_PRECISION", &ival) != CONFIG_FALSE) {
		geohash_setprec(ival);
	}

#if WITH_HTTP
	if (config_lookup_string(cf, "OTR_HTTPHOST", &value) != CONFIG_FALSE) {
		if (ud->http_host) free(ud->http_host);
		ud->http_host = (value) ? strdup(value) : NULL;
	}
	if (config_lookup_int(cf, "OTR_HTTPPORT", &ival) != CONFIG_FALSE) {
		ud->http_port = ival;
	}
//.........这里部分代码省略.........
开发者ID:owntracks,项目名称:recorder,代码行数:101,代码来源:misc.c


示例12: main

int main(int argc, char *argv[])
{
    SDL_Joystick *joy = NULL;
    int t1, t0, uniform;

    if (!fs_init(argv[0]))
    {
        fprintf(stderr, "Failure to initialize virtual file system: %s\n",
                fs_error());
        return 1;
    }

    lang_init("neverball");

    parse_args(argc, argv);

    config_paths(data_path);
    make_dirs_and_migrate();

    /* Initialize SDL system and subsystems */

    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) == -1)
    {
        fprintf(stderr, "%s\n", SDL_GetError());
        return 1;
    }

    /* Intitialize the configuration */

    config_init();
    config_load();

    /* Initialize the joystick. */

    if (config_get_d(CONFIG_JOYSTICK) && SDL_NumJoysticks() > 0)
    {
        joy = SDL_JoystickOpen(config_get_d(CONFIG_JOYSTICK_DEVICE));
        if (joy)
            SDL_JoystickEventState(SDL_ENABLE);
    }

    /* Initialize the audio. */

    audio_init();
    tilt_init();

    /* Initialize the video. */

    if (!video_init(TITLE, ICON))
        return 1;

    init_state(&st_null);

    /* Initialise demo playback. */

    if (demo_path && fs_add_path(dir_name(demo_path)) &&
        progress_replay(base_name(demo_path, NULL)))
    {
        demo_play_goto(1);
        goto_state(&st_demo_play);
    }
    else
        goto_state(&st_title);

    /* Run the main game loop. */

    uniform = config_get_d(CONFIG_UNIFORM);
    t0 = SDL_GetTicks();

    while (loop())
    {
        t1 = SDL_GetTicks();

        if (uniform)
        {
            /* Step the game uniformly, as configured. */

            int u;

            for (u = 0; u < abs(uniform); ++u)
            {
                st_timer(DT);
                t0 += (int) (DT * 1000);
            }
        }
        else
        {
            /* Step the game state at least up to the current time. */

            while (t1 > t0)
            {
                st_timer(DT);
                t0 += (int) (DT * 1000);
            }
        }

        /* Render. */

        st_paint(0.001f * t0);
        video_swap();
//.........这里部分代码省略.........
开发者ID:lubomyr,项目名称:Neverball,代码行数:101,代码来源:main.c


示例13: main


//.........这里部分代码省略.........

    umask(0);
  }

  tvheadend_running = 1;

  /* Start log thread (must be done post fork) */
  tvhlog_start();

  /* Alter logging */
  if (opt_fork)
    tvhlog_options &= ~TVHLOG_OPT_STDERR;
  if (!isatty(2))
    tvhlog_options &= ~TVHLOG_OPT_DECORATE;
  
  /* Initialise clock */
  pthread_mutex_lock(&global_lock);
  time(&dispatch_clock);

  /* Signal handling */
  sigfillset(&set);
  sigprocmask(SIG_BLOCK, &set, NULL);
  trap_init(argv[0]);

  /* SSL library init */
  OPENSSL_config(NULL);
  SSL_load_error_strings();
  SSL_library_init();

  /* Initialise configuration */
  notify_init();
  idnode_init();
  spawn_init();
  config_init(opt_nobackup == 0);

  /**
   * Initialize subsystems
   */

  epg_in_load = 1;

  tvhthread_create(&tasklet_tid, NULL, tasklet_thread, NULL);

  dbus_server_init(opt_dbus, opt_dbus_session);

  intlconv_init();
  
  api_init();

  fsmonitor_init();

  libav_init();

  tvhtime_init();

  profile_init();

  imagecache_init();

  http_client_init(opt_user_agent);
  esfilter_init();

  bouquet_init();

  service_init();
开发者ID:bigbig6,项目名称:tvheadend,代码行数:66,代码来源:main.c


示例14: main

int
main(
    int		argc,
    char **	argv)
{
#ifdef GNUTAR
    int i;
    char *e;
    char *dbf;
    char *cmdline;
    GPtrArray *array = g_ptr_array_new();
    gchar **strings;
    char **new_argv;
#endif

    if (argc > 1 && argv[1] && g_str_equal(argv[1], "--version")) {
	printf("runtar-%s\n", VERSION);
	return (0);
    }

    /*
     * Configure program for internationalization:
     *   1) Only set the message locale for now.
     *   2) Set textdomain for all amanda related programs to "amanda"
     *      We don't want to be forced to support dozens of message catalogs.
     */
    setlocale(LC_MESSAGES, "C");
    textdomain("amanda"); 

    safe_fd(-1, 0);
    safe_cd();

    set_pname("runtar");

    /* Don't die when child closes pipe */
    signal(SIGPIPE, SIG_IGN);

    dbopen(DBG_SUBDIR_CLIENT);
    config_init(CONFIG_INIT_CLIENT, NULL);

    if (argc < 3) {
	error(_("Need at least 3 arguments\n"));
	/*NOTREACHED*/
    }

    dbprintf(_("version %s\n"), VERSION);

    if (!g_str_equal(argv[3], "--create")) {
	error(_("Can only be used to create tar archives\n"));
	/*NOTREACHED*/
    }

#ifndef GNUTAR

    g_fprintf(stderr,_("gnutar not available on this system.\n"));
    dbprintf(_("%s: gnutar not available on this system.\n"), argv[0]);
    dbclose();
    return 1;

#else

    /*
     * Print out version information for tar.
     */
    do {
	FILE *	version_file;
	char	version_buf[80];

	if ((version_file = popen(GNUTAR " --version 2>&1", "r")) != NULL) {
	    if (fgets(version_buf, (int)sizeof(version_buf), version_file) != NULL) {
		dbprintf(_(GNUTAR " version: %s\n"), version_buf);
	    } else {
		if (ferror(version_file)) {
		    dbprintf(_(GNUTAR " version: Read failure: %s\n"), strerror(errno));
		} else {
		    dbprintf(_(GNUTAR " version: Read failure; EOF\n"));
		}
	    }
	} else {
	    dbprintf(_(GNUTAR " version: unavailable: %s\n"), strerror(errno));
	}
    } while(0);

#ifdef WANT_SETUID_CLIENT
    check_running_as(RUNNING_AS_CLIENT_LOGIN | RUNNING_AS_UID_ONLY);
    if (!become_root()) {
	error(_("error [%s could not become root (is the setuid bit set?)]\n"), get_pname());
	/*NOTREACHED*/
    }
#else
    check_running_as(RUNNING_AS_CLIENT_LOGIN);
#endif

    /* skip argv[0] */
    argc--;
    argv++;

    dbprintf(_("config: %s\n"), argv[0]);
    if (!g_str_equal(argv[0], "NOCONFIG"))
	dbrename(argv[0], DBG_SUBDIR_CLIENT);
//.........这里部分代码省略.........
开发者ID:alexpaulzor,项目名称:amanda,代码行数:101,代码来源:runtar.c


示例15: main

int main(int argc, char **argv) {
    config_init(argc, argv);
    initproctitle(argc, argv);

    return _main(&CONFIG);
}
开发者ID:karlpilkington,项目名称:relay,代码行数:6,代码来源:relay.c


示例16: pam_sm_authenticate

/**
 * This function performs the task of authenticating the user
 * @param pam_handle The PAM handle
 * @param pam_flags The authentication flags
 * @param pam_argc The system arguments count
 * @param pam_argv The system arguments array
 * @return A PAM return code
 */
PAM_EXTERN int 
pam_sm_authenticate(pam_handle_t *pam_handle, int pam_flags, int pam_argc, 
const char **pam_argv)
{
    /* The module dialogs */
    struct pam_message *pam_dialog_message[1];
    struct pam_message pam_dialog_message_ptr[1];
    struct pam_response *pam_dialog_response;
    char *pam_dialog_input;

    /* The module parameters */
    int pam_config_permit_bypass = 0;
    int pam_config_code_length = 8;

    /* The module configuration */
    config_t pam_config;
    FILE *pam_config_fd;

    /* The module status */
    int pam_status;

    /* The module data */
    const char *pam_user;
    char pam_email[320];
    char *pam_code;
    char *pam_str_buffer;

    /* The module randomization */
    FILE *pam_urandom_fd;
    int pam_random;

    /* Init PAM dialog variables */
    pam_dialog_message[0] = &pam_dialog_message_ptr[0];
    pam_dialog_response = NULL;

    /* Init configuration */
    config_init(&pam_config);

    /* Init configuration file stream */
    if((pam_config_fd = fopen("/etc/aurora/email.conf", "r")) == NULL)
    {
        /* An error occurs */
        pam_dialog_message_ptr[0].msg_style = PAM_ERROR_MSG;
        pam_dialog_message_ptr[0].msg = 
            "[ERROR] Unable to open configuration";
        pam_converse(pam_handle, 1, pam_dialog_message, &pam_dialog_response);

        /* Properly destroy the configuration */
        config_destroy(&pam_config);

        /* Reject authentication */
        return PAM_AUTH_ERR;
    }

    /* Read and parse the configuration file */
    if(config_read(&pam_config, pam_config_fd) == CONFIG_FALSE)
    {
        /* An error occurs */
        pam_dialog_message_ptr[0].msg_style = PAM_ERROR_MSG;
        pam_dialog_message_ptr[0].msg = 
            "[ERROR] Unable to read configuration";
        pam_converse(pam_handle, 1, pam_dialog_message, &pam_dialog_response);

        /* Properly destroy the configuration */
        config_destroy(&pam_config);

        /* Properly destroy the configuration file stream */
        fclose(pam_config_fd);

        /* Reject authentication */
        return PAM_AUTH_ERR;
    }

    /* Get settings */
    config_lookup_int(&pam_config, "code_length", 
        &pam_config_code_length);
    config_lookup_int(&pam_config, "permit_bypass", 
        &pam_config_permit_bypass);

    /* Properly destroy the configuration */
    config_destroy(&pam_config);

    /* Get user login */
    if((pam_status = pam_get_user(pam_handle, &pam_user, "login: ")) 
        != PAM_SUCCESS)
    {
        /* An error occurs */
        pam_dialog_message_ptr[0].msg_style = PAM_ERROR_MSG;
        pam_dialog_message_ptr[0].msg = "[ERROR] Unable to get username";
        pam_converse(pam_handle, 1, pam_dialog_message, &pam_dialog_response);

        /* Reject authentication */
//.........这里部分代码省略.........
开发者ID:toulet,项目名称:pam-aurora,代码行数:101,代码来源:pam_aurora_email.c


示例17: pam_directory_lookup

/**
 * This function looks for user data in directory
 * @param pam_handle The PAM handle
 * @param pam_user_login The user login
 * @param pam_user_email The email destination
 * @return A PAM return code
 */
int
pam_directory_lookup(pam_handle_t *pam_handle, const char *pam_user_login, 
char *pam_user_email)
{
    /* The module dialogs */
    struct pam_message *pam_dialog_message[1];
    struct pam_message pam_dialog_message_ptr[1];
    struct pam_response *pam_dialog_response;

    /* The module directory */
    config_t pam_directory;
    FILE *pam_directory_fd;
    config_setting_t *pam_directory_emails;

    /* The email buffer */
    const char *stored_user_email;

    /* Init PAM dialog variables */
    pam_dialog_message[0] = &pam_dialog_message_ptr[0];
    pam_dialog_response = NULL;

    /* Init configuration */
    config_init(&pam_directory);

    /* Init configuration file stream */
    if((pam_directory_fd = fopen("/etc/aurora/directory.conf", "r")) == NULL)
    {
        /* An error occurs */
        pam_dialog_message_ptr[0].msg_style = PAM_ERROR_MSG;
        pam_dialog_message_ptr[0].msg = 
            "[ERROR] Unable to open directory";
        pam_converse(pam_handle, 1, pam_dialog_message, &pam_dialog_response);

        /* Properly destroy the directory */
        config_destroy(&pam_directory);

        /* Reject authentication */
        return PAM_AUTH_ERR;
    }

    /* Read and parse the configuration file */
    if(config_read(&pam_directory, pam_directory_fd) == CONFIG_FALSE)
    {
        /* An error occurs */
        pam_dialog_message_ptr[0].msg_style = PAM_ERROR_MSG;
        pam_dialog_message_ptr[0].msg = 
            "[ERROR] Unable to read directory";
        pam_converse(pam_handle, 1, pam_dialog_message, &pam_dialog_response);

        /* Properly destroy the directory */
        config_destroy(&pam_directory);

        /* Properly destroy the directory file stream */
        fclose(pam_directory_fd);

        /* Reject authentication */
        return PAM_AUTH_ERR;
    }

    /* Get the emails collection */
    pam_directory_emails = config_lookup(&pam_directory, "emails");

    /* Look for user email */
    if (config_setting_lookup_string(pam_directory_emails, 
        pam_user_login, &stored_user_email) == CONFIG_FALSE)
    {
        /* An error occurs */
        pam_dialog_message_ptr[0].msg_style = PAM_ERROR_MSG;
        pam_dialog_message_ptr[0].msg = 
            "[ERROR] Email not found in directory";
        pam_converse(pam_handle, 1, pam_dialog_message, &pam_dialog_response);

        /* Properly destroy the directory */
        config_destroy(&pam_directory);

        /* Reject authentication */
        return PAM_AUTH_ERR;
    }

    /* Check the email address length */
    if(strlen(stored_user_email) > 320)
    {
        /* An error occurs */
        pam_dialog_message_ptr[0].msg_style = PAM_ERROR_MSG;
        pam_dialog_message_ptr[0].msg = 
            "[ERROR] Email address too long (max 320 chars)";
        pam_converse(pam_handle, 1, pam_dialog_message, &pam_dialog_response);

        /* Properly destroy the directory */
        config_destroy(&pam_directory);

        /* Reject authentication */
        return PAM_AUTH_ERR;
//.........这里部分代码省略.........
开发者ID:toulet,项目名称:pam-aurora,代码行数:101,代码来源:pam_aurora_email.c


示例18: main

int
main(
    int		argc,
    char **	argv)
{
#ifndef ERRMSG
    char *dump_program;
    int i;
    char *e;
    char *cmdline;
#endif /* ERRMSG */

    /*
     * Configure program for internationalization:
     *   1) Only set the message locale for now.
     *   2) Set textdomain for all amanda related programs to "amanda"
     *      We don't want to be forced to support dozens of message catalogs.
     */  
    setlocale(LC_MESSAGES, "C");
    textdomain("amanda"); 

    safe_fd(-1, 0);
    safe_cd();

    set_pname("rundump");

    /* Don't die when child closes pipe */
    signal(SIGPIPE, SIG_IGN);

    dbopen(DBG_SUBDIR_CLIENT);
    config_init(CONFIG_INIT_CLIENT, NULL);

    if (argc < 3) {
	error(_("Need at least 3 arguments\n"));
	/*NOTREACHED*/
    }

    dbprintf(_("version %s\n"), VERSION);

#ifdef ERRMSG							/* { */

    g_fprintf(stderr, ERRMSG);
    dbprintf("%s: %s", argv[0], ERRMSG);
    dbclose();
    return 1;

#else								/* } { */

#ifdef WANT_SETUID_CLIENT
    check_running_as(RUNNING_AS_CLIENT_LOGIN | RUNNING_AS_UID_ONLY);
    if (!become_root()) {
	error(_("error [%s could not become root (is the setuid bit set?)]\n"), get_pname());
	/*NOTREACHED*/
    }
#else
    check_running_as(RUNNING_AS_CLIENT_LOGIN);
#endif

    /* skip argv[0] */
    argc--;
    argv++;

    dbprintf(_("config: %s\n"), argv[0]);
    if (strcmp(argv[0], "NOCONFIG") != 0)
	dbrename(argv[0], DBG_SUBDIR_CLIENT);
    argc--;
    argv++;

#ifdef XFSDUMP

    if (strcmp(argv[0], "xfsdump") == 0)
        dump_program = XFSDUMP;
    else /* strcmp(argv[0], "xfsdump") != 0 */

#endif

#ifdef VXDUMP

    if (strcmp(argv[0], "vxdump") == 0)
        dump_program = VXDUMP;
    else /* strcmp(argv[0], "vxdump") != 0 */

#endif

#ifdef VDUMP

    if (strcmp(argv[0], "vdump") == 0)
	dump_program = VDUMP;
    else /* strcmp(argv[0], "vdump") != 0 */

#endif

#if defined(DUMP)
        dump_program = DUMP;
#else
# if defined(XFSDUMP)
        dump_program = XFSDUMP;
# else
#  if defined(VXDUMP)
	dump_program = VXDUMP;
//.........这里部分代码省略.........
开发者ID:malclocke,项目名称:amanda,代码行数:101,代码来源:rundump.c


示例19: readConf

void readConf(const char *aFilename, Config * config) {
  config_t cfg;
  config_init(&cfg);

  // Open config file
  if (!config_read_file(&cfg, aFilename)) {
    error("Can't open config file %s: %d - %s\n", aFilename, config_error_line(&cfg), config_error_text(&cfg));
    config_destroy(&cfg);
    exit(-1);
  }

  config->filename = aFilename;

  config->videoType = UNKNOWN;
  config->ledType = EMPTY;
  config->ledControllerType = NONE;

  // Load config groups
  config_setting_t * video = config_lookup(&cfg, "video");
  if (!video) {
    error("Missing video configuration in config file %s\n", aFilename);
    exit(-1);
  }

  config_setting_t * videoDevice = config_lookup(&cfg, "video/device");
  if (!videoDevice) {
    error("Missing video device configuration in config file %s\n", aFilename);
    exit(-1);
  }

  config_setting_t * leds = config_lookup(&cfg, "leds");
  if (!leds) {
    error("Missing leds configuration in config file %s\n", aFilename);
    exit(-1);
  }

  config_setting_t * ledController = config_lookup(&cfg, "leds/controller");
  if (!ledController) {
    error("Missing led controller configuration in config file %s\n", aFilename);
    exit(-1);
  }

  // Load params

  // Video width
  int width;
  if (!config_setting_lookup_int(video, "width", &width))
    confError(aFilename, "video/width");

  config->width = width;

  // Video height
  int height;
  if (!config_setting_lookup_int(video, "height", &height))
    confError(aFilename, "video/height");

  config->height = height;

  // Video device type
  const char *videoDeviceType;
  if (!config_setting_lookup_string(videoDevice, "type", &videoDeviceType))
    confError(aFilename, "video/device/type");

  if (strcmp(videoDeviceType, "CAPTURER") == 0) config->videoType = CAPTURER;
  if (strcmp(videoDeviceType, "PLAYER") == 0) config->videoType = PLAYER; 
  if (config->videoType == UNKNOWN) confInvalid(aFilename, "video/device/type", videoDeviceType);

  // Video device path
  if (!config_setting_lookup_string(videoDevice, "path", &config->videoPath))
    confError(aFilename, "video/device/path");

  // Led type
  const char *ledDeviceType;
  if (!config_setting_lookup_string(leds, "type", &ledDeviceType))
    confError(aFilename, "leds/type");

  if (strcmp(ledDeviceType, "WS2801") == 0) config->ledType = WS2801;
  if (strcmp(ledDeviceType, "WS2812B") == 0) config->ledType = WS2812B;
  if (strcmp(ledDeviceType, "TM1804") == 0) config->ledType = TM1804;
  if (config->ledType == EMPTY) confInvalid(aFilename, "leds/type", ledDeviceType);

  // Leds left
  if (!config_setting_lookup_int(leds, "left", &config->ledsLeft))
    confError(aFilename, "leds/left");

  // Leds up
  if (!config_setting_lookup_int(leds, "up", &config->ledsUp))
    confError(aFilename, "leds/up");

  // Leds right
  if (!config_setting_lookup_int(leds, "right", &config->ledsRight))
    confError(aFilename, "leds/right");

  // Leds down
  if (!config_setting_lookup_int(leds, "down", &config->ledsDown))
    confError(aFilename, "leds/down");

  // Led controller type
  const char *ledControllerDeviceType;
  if (!config_setting_lookup_string(ledController, "type", &ledControllerDeviceType))
//.........这里部分代码省略.........
开发者ID:acperez,项目名称:AmbiLed,代码行数:101,代码来源:ambiled.cpp


示例20: init_register

void init_register(const char *scfile){
    share_config_file = strdup(scfile);
      
  // try to open share_config_file for reading
  // if it fails try writing a default config file 
      sem_init(&cfgsem,0,1);   
	  strcat(servername,"Unknown");
	  FILE *file;
	  file = fopen(share_config_file, "r");
	  if (file) { 
		  fclose(file);
	  }else{
		  file = fopen(share_config_file,"w");
		  if (file) {
			fprintf(file,"%s\n","# Simple config file for ghpsdr3's dspserver.");
			fprintf(file,"%s\n","# default file is located at ~/dspserver.conf when dsp server is started with --share");
			fprintf(file,"%s\n","# The information below will be supplied to a web database which will aid QtRadio");
			fprintf(file,"%s\n","# users find active dspservers to connect to.  You may also see the current list at");
			fprintf(file,"%s\n","# http://napan.ca/qtradio/qtradio.pl");
			fprintf(file,"%s\n","# valid fields are call, location, band, rig and ant");
			fprintf(file,"%s\n","# lines must end with ; and any characters after a # is a comment and ignored");
			fprintf(file,"%s\n","# field values must be enclosed with \" ie: \"xxxx\"");
			fprintf(file,"%s\n","# This default file will be created if dspserver is started with the --share option and ~/dspserver.cfg does not exist");
			fprintf(file,"%s\n","# You may also start dspserver with an alternate config file by starting dspserver with --shareconfig /home/alternate_filename.conf");
			fprintf(file,"%s\n","# Note field names are all lowercase!");

			fprintf(file,"\n%s\n","call = \"Unknown\";");
			fprintf(file,"%s\n","location = \"Unknown\";");
			fprintf(file,"%s\n","band = \"Unknown\";");
			fprintf(file,"%s\n","rig = \"Unknown\";");
			fprintf(file,"%s\n","ant = \"Unknown\";");
			fprintf(file,"%s\n","share = \"yes\"; # Can be yes, no");
			fprintf(file,"%s\n","lookupcountry = \"no\"; # Can be yes, no");
			fprintf(file,"\n%s\n","#### Following are new TX options #####");
			fprintf(file,"\n%s\n","tx = \"no\";  #Can be: no, yes, password");
			fprintf(file,"\n%s\n","#ve9gj = \"secretpassword\";  #add users/passwords one per line (Remove leading # ! max 20 characters each");
			fprintf(file,"\n%s\n","groupnames = [\"txrules1\"];  #add group or rulesset names in [\"name1\", \"name2\"]; format (max 20 characters each");
			fprintf(file,"\n%s\n", "# Add user names in [\"call1\", \"call2\"]; format to list members for each groupname above with an suffix of \"_members\" ");
			fprintf(file,"%s\n","txrules1_members = [\"ve9gj\", \"call2\"]; ");
			fprintf(file,"\n%s\n","# Rule sets are defined as group or rulesset name =( (\"mode\", StartFreq in Mhz, End Freq in Mhz),(\"mode\", StartFreq in Mhz, End Freq in Mhz) );");
			fprintf(file,"%s\n","#  Valid modes are  * SSB, CW, AM, DIG, FM, DRM ,SAM, SPEC Where * means any mode is OK");
			fprintf(file,"%s\n","#  The two rules below allow any mode on 20M and CW only on the bottom 100Khz of 80M");
			fprintf(file,"%s\n","#  You can make as many rules and rulesets as you wish. The first matching rule will allow TX");
			fprintf(file,"\n%s\n","txrules1 = (\n     (\"*\",14.0,14.350), # mode, StartFreq Mhz, EndFreq Mhz");
			fprintf(file,"%s\n","     (\"CW\",3.5,3.6)");
			fprintf(file,"%s\n","          );");
			
			fclose(file);
			fprintf(stderr,"%s\n", "**********************************************************");
			fprintf(stderr,"%s\n", "  A new  dspserver config file template has been created at: ");
			fprintf(stderr,"  %s\n", share_config_file);
			fprintf(stderr,"%s\n", "  Please edit this file and fill in your station details!");
			fprintf(stderr,"%s\n", "***********************************************************");
		  } else{
			  fprintf(stderr, "Error Can't create config file %s\n", share_config_file);
		  }
		  
	  }           
  
  
  
  
  const char *str;
  config_init(&cfg);
  if(! config_read_file(&cfg, share_config_file))
  {
    fprintf(stderr, "Error - %s\n",  config_error_text(&cfg));
    config_destroy(&cfg);
    
  }else{
	 if(config_lookup_string(&cfg, "call", &str)){
         call = str;
         strncpy(servername,str, 20);
     }
     if(config_lookup_string(&cfg, "location", &str)){
         location = str;
     }
     if(config_lookup_string(&cfg, "band", &str)){
         band = str;
     }
	 if(config_lookup_string(&cfg, "rig", &str)){
         rig = str;
     }
     if(config_lookup_string(&cfg, "ant", &str)){
         ant = str;
     }
     if(config_lookup_string(&cfg, "share", &str)){
         if (strcmp(str, "yes") == 0){
			 toShareOrNotToShare = 1;
         }else{
             toShareOrNotToShare = 0;
         }
     }else{
		fprintf(stderr, "Conf File Error - %s%s%s\n",  "Your ",share_config_file, " is missing a share= setting!!" );
	 } 
     if(config_lookup_string(&cfg, "lookupcountry", &str)){
         if (strcmp(str, "yes") == 0){
			 setprintcountry();
         }
     }else{
//.........这里部分代码省略.........
开发者ID:ktims,项目名称:ghpsdr3-alex,代码行数:101,代码来源:register.c



注:本文中的config_init函数


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ config_item_name函数代码示例发布时间:2022-05-30
下一篇:
C++ config_get_value函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap