当前位置: 首页>>代码示例>>C++>>正文


C++ xsetenv函数代码示例

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


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

示例1: set_global_stop_on_not_reportable

void set_global_stop_on_not_reportable(bool enabled, int flags/*unused - persistent*/)
{
    assert_global_configuration_initialized();

    if (enabled)
        xsetenv(STOP_ON_NOT_REPORTABLE, "1");
    else
        xsetenv(STOP_ON_NOT_REPORTABLE, "0");
}
开发者ID:abrt,项目名称:libreport,代码行数:9,代码来源:global_configuration.c

示例2: euidgid

static void euidgid(char *user)
{
	struct bb_uidgid_t ugid;

	if (!get_uidgid(&ugid, user, 1)) {
		bb_error_msg_and_die("unknown user/group: %s", user);
	}
	xsetenv("GID", utoa(ugid.gid));
	xsetenv("UID", utoa(ugid.uid));
}
开发者ID:Predator-SD,项目名称:Tarixy,代码行数:10,代码来源:chpst.c

示例3: setenvvars_system

/* Setting munin specific vars */
static void setenvvars_system() {
	/* Some locales use "," as decimal separator.
	 * This can mess up a lot of plugins. */
	xsetenv("LC_ALL", "C", yes);

	/* LC_ALL should be enough, but some plugins don't
	 * follow specs (#1014) */
	xsetenv("LANG", "C", yes);

	/* PATH should be *very* sane by default. Can be
	 * overrided via config file if needed
	 * (Closes #863 and #1128).  */
	xsetenv("PATH", "/usr/sbin:/usr/bin:/sbin:/bin", yes);
}
开发者ID:char101,项目名称:munin-c,代码行数:15,代码来源:node.c

示例4: change_user

static void change_user(const struct passwd *pas)
{
	xsetenv("USER", pas->pw_name);
	xsetenv("HOME", pas->pw_dir);
	xsetenv("SHELL", DEFAULT_SHELL);

	/* initgroups, setgid, setuid */
	change_identity(pas);

	if (chdir(pas->pw_dir) < 0) {
		bb_perror_msg("chdir(%s) by %s failed",
				pas->pw_dir, pas->pw_name);
		xchdir("/tmp");
	}
}
开发者ID:0xD34D,项目名称:android_external_busybox,代码行数:15,代码来源:crontab.c

示例5: main

// main takes care of OS-specific startup and dispatches to xmain.
void
main(int argc, char **argv)
{
	Buf b;

	setvbuf(stdout, nil, _IOLBF, BUFSIZ);
	setvbuf(stderr, nil, _IOLBF, BUFSIZ);

	binit(&b);

	rfork(RFENVG);

	slash = "/";
	gohostos = "plan9";

	xgetenv(&b, "objtype");
	if(b.len == 0)
		fatal("$objtype is unset");
	gohostarch = btake(&b);

	xgetenv(&b, "GOBIN");
	if(b.len == 0){
		bpathf(&b, "/%s/bin", gohostarch);
		xsetenv("GOBIN", bstr(&b));
	}

	srand(time(0)+getpid());
	init();
	xmain(argc, argv);

	bfree(&b);
	exits(nil);
}
开发者ID:icattlecoder,项目名称:go,代码行数:34,代码来源:plan9.c

示例6: run

/**
 * Run a script.
 * argv[0]:intf argv[1]:script_name argv[2]:junk argv[3]:NULL
 */
static int run(char *argv[3], const char *param, struct in_addr *ip)
{
	int status;
	char *addr = addr; /* for gcc */
	const char *fmt = "%s %s %s" + 3;

	argv[2] = (char*)param;

	VDBG("%s run %s %s\n", argv[0], argv[1], argv[2]);

	if (ip) {
		addr = inet_ntoa(*ip);
		xsetenv("ip", addr);
		fmt -= 3;
	}
	if (verbose)
		bb_info_msg(fmt, argv[2], argv[0], addr);

	status = spawn_and_wait(argv + 1);
	if (status < 0) {
		bb_perror_msg("%s %s %s" + 3, argv[2], argv[0]);
		return -errno;
	}
	if (status != 0)
		bb_error_msg("script %s %s failed, exitcode=%d", argv[1], argv[2], status & 0xff);
	return status;
}
开发者ID:sdg7,项目名称:wl500g,代码行数:31,代码来源:zcip.c

示例7: edir

/* TODO: use recursive_action? */
static NOINLINE void edir(const char *directory_name)
{
	int wdir;
	DIR *dir;
	struct dirent *d;
	int fd;

	wdir = xopen(".", O_RDONLY | O_NDELAY);
	xchdir(directory_name);
	dir = xopendir(".");
	for (;;) {
		char buf[256];
		char *tail;
		int size;

		errno = 0;
		d = readdir(dir);
		if (!d) {
			if (errno)
				bb_perror_msg_and_die("readdir %s",
						directory_name);
			break;
		}
		if (d->d_name[0] == '.')
			continue;
		fd = open(d->d_name, O_RDONLY | O_NDELAY);
		if (fd < 0) {
			if ((errno == EISDIR) && directory_name) {
				if (option_mask32 & OPT_v)
					bb_perror_msg("warning: %s/%s is a directory",
						directory_name, d->d_name);
				continue;
			}
			bb_perror_msg_and_die("open %s/%s",
						directory_name, d->d_name);
		}
		size = full_read(fd, buf, sizeof(buf)-1);
		close(fd);
		if (size < 0)
			bb_perror_msg_and_die("read %s/%s",
					directory_name, d->d_name);
		if (size == 0) {
			unsetenv(d->d_name);
			continue;
		}
		buf[size] = '\n';
		tail = strchr(buf, '\n');
		/* skip trailing whitespace */
		while (1) {
			*tail = '\0';
			tail--;
			if (tail < buf || !isspace(*tail))
				break;
		}
		xsetenv(d->d_name, buf);
	}
	closedir(dir);
	xfchdir(wdir);
	close(wdir);
}
开发者ID:AlexShiLucky,项目名称:busybox,代码行数:61,代码来源:chpst.c

示例8: set_env_vars

static void set_env_vars(struct passwd *pas, const char *shell)
{
	/* POSIX requires crond to set up at least HOME, LOGNAME, PATH, SHELL.
	 * We assume crond inherited suitable PATH.
	 */
#if SETENV_LEAKS
	safe_setenv(&G.env_var_logname, "LOGNAME", pas->pw_name);
	safe_setenv(&G.env_var_user, "USER", pas->pw_name);
	safe_setenv(&G.env_var_home, "HOME", pas->pw_dir);
	safe_setenv(&G.env_var_shell, "SHELL", shell);
#else
	xsetenv("LOGNAME", pas->pw_name);
	xsetenv("USER", pas->pw_name);
	xsetenv("HOME", pas->pw_dir);
	xsetenv("SHELL", shell);
#endif
}
开发者ID:AlexShiLucky,项目名称:busybox,代码行数:17,代码来源:crond.c

示例9: setenvvars_munin

/* Setting munin specific vars */
static void setenvvars_munin() {
	/* munin-node will override this with the IP of the
	 * connecting master */
	if (client_ip != NULL && client_ip[0] != '\0') {
		xsetenv("MUNIN_MASTER_IP", client_ip, no);
	}

	/* Tell plugins about supported capabilities */
	xsetenv("MUNIN_CAP_MULTIGRAPH", "1", no);

	/* We only have one user, so using a fixed path */
	xsetenv("MUNIN_PLUGSTATE", "/var/tmp", no);
	xsetenv("MUNIN_STATEFILE", "/dev/null", no);

	/* That's where plugins should live */
	xsetenv("MUNIN_LIBDIR", "/usr/share/munin", no);
}
开发者ID:char101,项目名称:munin-c,代码行数:18,代码来源:node.c

示例10: set_global_create_private_ticket

void set_global_create_private_ticket(bool enabled, int flags/*unused - persistent*/)
{
    assert_global_configuration_initialized();

    if (enabled)
        xsetenv(CREATE_PRIVATE_TICKET, "1");
    else
        safe_unsetenv(CREATE_PRIVATE_TICKET);
}
开发者ID:abrt,项目名称:libreport,代码行数:9,代码来源:global_configuration.c

示例11: setup_environment

void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw )
{
	if ( loginshell ) {
		const char *term;

		/* Change the current working directory to be the home directory
		 * of the user.  It is a fatal error for this process to be unable
		 * to change to that directory.  There is no "default" home
		 * directory.
		 * Some systems default to HOME=/
		 */
		if ( chdir ( pw-> pw_dir )) {
			if ( chdir ( "/" )) {
				syslog ( LOG_WARNING, "unable to cd to %s' for user %s'\n", pw-> pw_dir, pw-> pw_name );
				bb_error_msg_and_die ( "cannot cd to home directory or /" );
			}
			fputs ( "warning: cannot change to home directory\n", stderr );
		}

		/* Leave TERM unchanged.  Set HOME, SHELL, USER, LOGNAME, PATH.
		   Unset all other environment variables.  */
		term = getenv ("TERM");
		clearenv ( );
		if ( term )
			xsetenv ( "TERM", term );
		xsetenv ( "HOME",    pw-> pw_dir );
		xsetenv ( "SHELL",   shell );
		xsetenv ( "USER",    pw-> pw_name );
		xsetenv ( "LOGNAME", pw-> pw_name );
		xsetenv ( "PATH",    ( pw-> pw_uid ? DEFAULT_LOGIN_PATH : DEFAULT_ROOT_LOGIN_PATH ));
	}
	else if ( changeenv ) {
		/* Set HOME, SHELL, and if not becoming a super-user,
		   USER and LOGNAME.  */
		xsetenv ( "HOME",  pw-> pw_dir );
		xsetenv ( "SHELL", shell );
		if  ( pw-> pw_uid ) {
			xsetenv ( "USER",    pw-> pw_name );
			xsetenv ( "LOGNAME", pw-> pw_name );
		}
	}
}
开发者ID:OpenHMR,项目名称:Open-HMR600,代码行数:42,代码来源:setup_environment.c

示例12: reset_classpath

/* Restore CLASSPATH to its previous value.  */
void
reset_classpath (char *old_classpath)
{
  if (old_classpath != NULL)
    {
      xsetenv (CLASSPATHVAR, old_classpath, 1);
      free (old_classpath);
    }
  else
    unsetenv (CLASSPATHVAR);
}
开发者ID:alan707,项目名称:senuti,代码行数:12,代码来源:classpath.c

示例13: run_login_script

static void run_login_script(struct passwd *pw, char *full_tty)
{
    char *t_argv[2];

    t_argv[0] = getenv("LOGIN_PRE_SUID_SCRIPT");
    if (t_argv[0]) {
        t_argv[1] = NULL;
        xsetenv("LOGIN_TTY", full_tty);
        xsetenv("LOGIN_USER", pw->pw_name);
        xsetenv("LOGIN_UID", utoa(pw->pw_uid));
        xsetenv("LOGIN_GID", utoa(pw->pw_gid));
        xsetenv("LOGIN_SHELL", pw->pw_shell);
        spawn_and_wait(t_argv);	/* NOMMU-friendly */
        unsetenv("LOGIN_TTY");
        unsetenv("LOGIN_USER");
        unsetenv("LOGIN_UID");
        unsetenv("LOGIN_GID");
        unsetenv("LOGIN_SHELL");
    }
}
开发者ID:Buckmarble,项目名称:android_external_busybox,代码行数:20,代码来源:login.c

示例14: main

int
main (int argc, char *argv[])
{
  char *s;
  int result = 0;

  /* Clean up environment.  */
  unsetenv ("LANGUAGE");
  unsetenv ("LC_ALL");
  unsetenv ("LC_MESSAGES");
  unsetenv ("LC_CTYPE");
  unsetenv ("LANG");
  unsetenv ("OUTPUT_CHARSET");

  xsetenv ("LC_ALL", argv[1], 1);
  setlocale (LC_ALL, "");
  textdomain ("codeset");
  bindtextdomain ("codeset", "gt-4");

  /* Here we expect output in ISO-8859-1.
     Except on Darwin 7 or newer and on BeOS, for which locale_charset ()
     always returns "UTF-8" (see config.charset).  */
#if !((defined __APPLE__ && defined __MACH__) || defined __BEOS__)
  s = gettext ("cheese");
  if (strcmp (s, "K\344se"))
    {
      fprintf (stderr, "call 1 returned: %s\n", s);
      result = 1;
    }
#endif

  bind_textdomain_codeset ("codeset", "UTF-8");

  /* Here we expect output in UTF-8.  */
  s = gettext ("cheese");
  if (strcmp (s, "K\303\244se"))
    {
      fprintf (stderr, "call 2 returned: %s\n", s);
      result = 1;
    }

  bind_textdomain_codeset ("codeset", "ISO-8859-1");

  /* Here we expect output in ISO-8859-1.  */
  s = gettext ("cheese");
  if (strcmp (s, "K\344se"))
    {
      fprintf (stderr, "call 3 returned: %s\n", s);
      result = 1;
    }

  return result;
}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:53,代码来源:gettext-4-prg.c

示例15: modify_environment

static void
modify_environment (const struct passwd *pw, const char *shell)
{
  if (simulate_login)
    {
      /* Leave TERM unchanged.  Set HOME, SHELL, USER, LOGNAME, PATH.
         Unset all other environment variables.  */
      char *term = getenv ("TERM");
      if (term)
	term = xstrdup (term);
      environ = xmalloc ((6 + !!term) * sizeof (char *));
      environ[0] = NULL;
      if (term) {
	xsetenv ("TERM", term, 1);
	free(term);
      }
      xsetenv ("HOME", pw->pw_dir, 1);
      if (shell)
	xsetenv ("SHELL", shell, 1);
      xsetenv ("USER", pw->pw_name, 1);
      xsetenv ("LOGNAME", pw->pw_name, 1);
      set_path(pw);
    }
  else
    {
      /* Set HOME, SHELL, and (if not becoming a superuser)
	 USER and LOGNAME.  */
      if (change_environment)
        {
          xsetenv ("HOME", pw->pw_dir, 1);
	  if (shell)
            xsetenv ("SHELL", shell, 1);
	  if (getlogindefs_bool ("ALWAYS_SET_PATH", 0))
	    set_path(pw);

          if (pw->pw_uid)
            {
              xsetenv ("USER", pw->pw_name, 1);
              xsetenv ("LOGNAME", pw->pw_name, 1);
            }
        }
    }

  export_pamenv ();
}
开发者ID:JohnLih,项目名称:util-linux,代码行数:45,代码来源:su-common.c


注:本文中的xsetenv函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。