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


C++ xbasename函数代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
	log_options_t opts = LOG_OPTS_STDERR_ONLY;
	int rc = 0;

	slurm_conf_init(NULL);
	log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_USER, NULL);
	parse_command_line(argc, argv);
	if (params.verbose) {
		opts.stderr_level += params.verbose;
		log_alter(opts, SYSLOG_FACILITY_USER, NULL);
	}

	while (1) {
		if ((!params.no_header) &&
		    (params.iterate || params.verbose || params.long_output))
			print_date();

		if (!params.clusters) {
			if (_get_info(false))
				rc = 1;
		} else if (_multi_cluster(params.clusters) != 0)
			rc = 1;
		if (params.iterate) {
			printf("\n");
			sleep(params.iterate);
		} else
			break;
	}

	exit(rc);
}
开发者ID:Q-Leap-Networks,项目名称:debian-slurm,代码行数:32,代码来源:sinfo.c

示例2: fput_main

int
fput_main(const struct cmd_fput_info* info)
{
    struct start_peer_info spi = {
        .cwd = info->cwd,
        .adb = info->adb,
        .transport = info->transport,
        .user = info->user,
    };

    struct cmd_xfer_stub_info xilocal = {
        .mode = "send",
        .filename = info->local,
        .xfer = info->xfer,
    };

    struct cmd_xfer_stub_info xiremote = {
        .mode = "recv",
        .filename = info->remote ?: ".",
        .desired_basename = (strcmp(info->local, "-") == 0
                             ? NULL
                             : xbasename(info->local)),
        .xfer = info->xfer,
    };

    return xfer_handle_command(&spi, &xilocal, &xiremote);
}
开发者ID:Learn-Android-app,项目名称:fb-adb,代码行数:27,代码来源:cmd_fput.c

示例3: main

int main(int argc, char **argv)
{
	int	i, port;
	const char	*prog = xbasename(argv[0]);
	char	*password = NULL, *username = NULL, *setvar = NULL;

	while ((i = getopt(argc, argv, "+hs:p:u:V")) != -1) {
		switch (i)
		{
		case 's':
			setvar = optarg;
			break;
		case 'p':
			password = optarg;
			break;
		case 'u':
			username = optarg;
			break;
		case 'V':
			printf("Network UPS Tools %s %s\n", prog, UPS_VERSION);
			exit(EXIT_SUCCESS);
		case 'h':
		default:
			usage(prog);
			exit(EXIT_SUCCESS);
		}
	}

	argc -= optind;
	argv += optind;

	if (argc < 1) {
		usage(prog);
		exit(EXIT_SUCCESS);
	}

	/* be a good little client that cleans up after itself */
	atexit(clean_exit);

	if (upscli_splitname(argv[0], &upsname, &hostname, &port) != 0) {
		fatalx(EXIT_FAILURE, "Error: invalid UPS definition.  Required format: upsname[@hostname[:port]]");
	}

	ups = xcalloc(1, sizeof(*ups));

	if (upscli_connect(ups, hostname, port, 0) < 0) {
		fatalx(EXIT_FAILURE, "Error: %s", upscli_strerror(ups));
	}

	if (setvar) {
		/* setting a variable */
		do_setvar(setvar, username, password);
	} else {
		/* if not, get the list of supported read/write variables */
		print_rwlist();
	}

	exit(EXIT_SUCCESS);
}
开发者ID:AlexLov,项目名称:nut,代码行数:59,代码来源:upsrw.c

示例4: rmfiles

static void rmfiles (char *prefix)
{
#ifdef _WIN32
    /* Win32 doesn't have POSIX dirent functions.  */
    WIN32_FIND_DATA ffd;
    HANDLE hnd;
    int go_on;
    string temp = concat (prefix, "*");
    string directory = xdirname (prefix);

    pushd (directory);
    hnd = FindFirstFile(temp, &ffd);
    go_on = (hnd != INVALID_HANDLE_VALUE);
    while (go_on) {
        /* FIXME: can this remove read-only files also, like rm -f does?  */
        DeleteFile(ffd.cFileName);
        go_on = (FindNextFile(hnd, &ffd) == TRUE);
    }
    FindClose(hnd);
    free(temp);
    popd ();
#else  /* not _WIN32 */
    DIR *dp;
    struct dirent *de;
    int temp_len = strlen (prefix);
    string directory = "./";
    const_string base = xbasename (prefix);

    /* Copy the directory part of PREFIX with the trailing slash, if any.  */
    if (base != prefix)
    {
        directory = (string) xmalloc (base - prefix + 1);
        directory[0] = '\0';
        strncat (directory, prefix, base - prefix);
    }

    /* Find matching files and delete them.  */
    if ((dp = opendir (directory)) != 0) {
        while ((de = readdir (dp)) != 0)
        {
            string found = concat (directory, de->d_name);

            if (FILESTRNCASEEQ (found, prefix, temp_len))
                /* On POSIX-compliant systems, including DJGPP, this will also
                   remove read-only files and empty directories, like rm -f does.  */
                if (remove (found))
                    perror (found);
            free (found);
        }
    }
#endif /* not _WIN32 */
}
开发者ID:texlive,项目名称:texlive-source,代码行数:52,代码来源:dvihp.c

示例5: set_default_pdf_filename

static void
set_default_pdf_filename(void)
{
  const char *dvi_base;

  dvi_base = xbasename(dvi_filename);
  if (mp_mode &&
      strlen(dvi_base) > 4 &&
      FILESTRCASEEQ(".mps", dvi_base + strlen(dvi_base) - 4)) {
    pdf_filename = NEW(strlen(dvi_base)+1, char);
    strncpy(pdf_filename, dvi_base, strlen(dvi_base) - 4);
    pdf_filename[strlen(dvi_base)-4] = '\0';
  } else if (strlen(dvi_base) > 4 &&
开发者ID:StickCui,项目名称:ptex-ng,代码行数:13,代码来源:dvipdfmx.c

示例6: copydir

static void
copydir( char *from, char *to, mode_t mode, char *group, char *owner,
         int dotimes, uid_t uid, gid_t gid)
{
  int i;
  DIR *dir;
  struct dirent *ep;
  struct stat sb;
  char *base, *destdir, *direntry, *destentry;

  base = xbasename(from);

  /* create destination directory */
  destdir = xmalloc((unsigned int)(strlen(to) + 1 + strlen(base) + 1));
  sprintf(destdir, "%s%s%s", to, _DIRECTORY_SEPARATOR, base);
  if (mkdirs(destdir, mode) != 0) {
    fail("cannot make directory %s\n", destdir);
    free(destdir);
    return;
  }

  if (!(dir = opendir(from))) {
    fail("cannot open directory %s\n", from);
    free(destdir);
    return;
  }

  direntry = xmalloc((unsigned int)PATH_MAX);
  destentry = xmalloc((unsigned int)PATH_MAX);

  while ((ep = readdir(dir)))
  {
    if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0)
      continue;

    sprintf(direntry, "%s/%s", from, ep->d_name);
    sprintf(destentry, "%s%s%s", destdir, _DIRECTORY_SEPARATOR, ep->d_name);

    if (stat(direntry, &sb) == 0 && S_ISDIR(sb.st_mode))
      copydir( direntry, destdir, mode, group, owner, dotimes, uid, gid );
    else
      copyfile( direntry, destentry, mode, group, owner, dotimes, uid, gid );
  }

  free(destdir);
  free(direntry);
  free(destentry);
  closedir(dir);
}
开发者ID:Ajunboys,项目名称:mozilla-os2,代码行数:49,代码来源:nsinstall.c

示例7: augbname

/*
 * Augment a buffer name with a number, if necessary
 *
 * If more than one file of the same basename() is open,
 * the additional buffers are named "file<2>", "file<3>", and
 * so forth.  This function adjusts a buffer name to
 * include the number, if necessary.
 */
int
augbname(char *bn, const char *fn, size_t bs)
{
	int	 count;
	size_t	 remain, len;

	if ((len = xbasename(bn, fn, bs)) >= bs)
		return (FALSE);

	remain = bs - len;
	for (count = 2; bfind(bn, FALSE) != NULL; count++)
		snprintf(bn + len, remain, "<%d>", count);

	return (TRUE);
}
开发者ID:WizardGed,项目名称:mg,代码行数:23,代码来源:buffer.c

示例8: do_kanji

static void
do_kanji (void) {
    const char **p;

    printf("\nAssuming CP %s 932\n", is_cp932_system ? "is" : "is not");

    for (p = ktab; *p; p++) {
        char *q = to_kanji(*p);
        char *r = xdirname(q);

        printf("%s -> %s + %s\n", *p, from_kanji(r), *p + (xbasename(q)-q));

        free (r);
        free (q);
    }
}
开发者ID:luigiScarso,项目名称:luatexjit,代码行数:16,代码来源:xdirtest.c

示例9: kpathsea_db_insert

void
kpathsea_db_insert (kpathsea kpse, const_string passed_fname)
{
  /* We might not have found ls-R, or even had occasion to look for it
     yet, so do nothing if we have no hash table.  */
  if (kpse->db.buckets) {
    const_string dir_part;
    string fname = xstrdup (passed_fname);
    string baseptr = fname + (xbasename (fname) - fname);
    const_string file_part = xstrdup (baseptr);

    *baseptr = '\0';  /* Chop off the filename.  */
    dir_part = fname; /* That leaves the dir, with the trailing /.  */

    /* Note that we do not assuse that these names have been normalized. */
    hash_insert (&(kpse->db), file_part, dir_part);
  }
}
开发者ID:starseeker,项目名称:ModTeX,代码行数:18,代码来源:db.c

示例10: main

int
main (int argc, char *argv[])
{
	log_options_t opts = LOG_OPTS_STDERR_ONLY ;
	int error_code = SLURM_SUCCESS;

	log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_USER, NULL);
	parse_command_line( argc, argv );
	if (params.verbose) {
		opts.stderr_level += params.verbose;
		log_alter(opts, SYSLOG_FACILITY_USER, NULL);
	}
	max_line_size = _get_window_width( );

	if (params.clusters)
		working_cluster_rec = list_peek(params.clusters);

	while (1) {
		if ((!params.no_header) &&
		    (params.iterate || params.verbose || params.long_list))
			_print_date ();

		if (!params.clusters) {
			if (_get_info(false))
				error_code = 1;
		} else if (_multi_cluster(params.clusters) != 0)
			error_code = 1;

		if ( params.iterate ) {
			printf( "\n");
			sleep( params.iterate );
		}
		else
			break;
	}

	if ( error_code != SLURM_SUCCESS )
		exit (error_code);
	else
		exit (0);
}
开发者ID:VURM,项目名称:slurm,代码行数:41,代码来源:squeue.c

示例11: main

int
main (int argc, char *argv[])
{
	log_options_t log_opts = LOG_OPTS_STDERR_ONLY ;
	int rc = 0;

	slurm_conf_init(NULL);
	log_init (xbasename(argv[0]), log_opts, SYSLOG_FACILITY_DAEMON, NULL);
	initialize_and_process_args(argc, argv);
	if (opt.verbose) {
		log_opts.stderr_level += opt.verbose;
		log_alter (log_opts, SYSLOG_FACILITY_DAEMON, NULL);
	}

	if (opt.clusters)
		rc = _multi_cluster(opt.clusters);
	else
		rc = _proc_cluster();

	exit(rc);
}
开发者ID:adammoody,项目名称:slurm,代码行数:21,代码来源:scancel.c

示例12: srun

int srun(int ac, char **av)
{
	int debug_level;
	log_options_t logopt = LOG_OPTS_STDERR_ONLY;
	bool got_alloc = false;
	List srun_job_list = NULL;

	slurm_conf_init(NULL);
	debug_level = _slurm_debug_env_val();
	logopt.stderr_level += debug_level;
	log_init(xbasename(av[0]), logopt, 0, NULL);
	_set_exit_code();

	if (slurm_select_init(1) != SLURM_SUCCESS )
		fatal( "failed to initialize node selection plugin" );

	if (switch_init(0) != SLURM_SUCCESS )
		fatal("failed to initialize switch plugins");

	_setup_env_working_cluster();

	init_srun(ac, av, &logopt, debug_level, 1);
	if (opt_list) {
		if (!_enable_pack_steps())
			fatal("Job steps that span multiple components of a heterogeneous job are not currently supported");
		create_srun_job((void **) &srun_job_list, &got_alloc, 0, 1);
	} else
		create_srun_job((void **) &job, &got_alloc, 0, 1);

	_setup_job_env(job, srun_job_list, got_alloc);
	_set_node_alias();
	_launch_app(job, srun_job_list, got_alloc);

	if ((global_rc & 0xff) == SIG_OOM)
		global_rc = 1;	/* Exit code 1 */

	return (int)global_rc;
}
开发者ID:supermanue,项目名称:slurm,代码行数:38,代码来源:srun.c

示例13: main

int main(int argc, char **argv)
{
    const char **p;
    kpathsea kpse = kpathsea_new();

    kpathsea_set_program_name (kpse, argv[0], NULL);

    printf("\n%s: name -> xdirname(name) + xbasename(name)\n\n",
           kpse->invocation_short_name);

    for (p = tab; *p; p++) {
        char *q = xdirname(*p);

        printf("%s -> %s + %s\n", *p, q, xbasename(*p));
        free (q);
    }

#if defined (WIN32)
    kanji_test();
#endif

    return 0;
}
开发者ID:luigiScarso,项目名称:luatexjit,代码行数:23,代码来源:xdirtest.c

示例14: stop_driver

/* handle sending the signal */
static void stop_driver(const ups_t *ups)
{
	char	pidfn[SMALLBUF];
	int	ret;
	struct stat	fs;

	upsdebugx(1, "Stopping UPS: %s", ups->upsname);

	snprintf(pidfn, sizeof(pidfn), "%s/%s-%s.pid", altpidpath(),
		ups->driver, ups->upsname);
	ret = stat(pidfn, &fs);

	if ((ret != 0) && (ups->port != NULL)) {
		snprintf(pidfn, sizeof(pidfn), "%s/%s-%s.pid", altpidpath(),
			ups->driver, xbasename(ups->port));
		ret = stat(pidfn, &fs);
	}

	if (ret != 0) {
		upslog_with_errno(LOG_ERR, "Can't open %s", pidfn);
		exec_error++;
		return;
	}

	upsdebugx(2, "Sending signal to %s", pidfn);

	if (testmode)
		return;

	ret = sendsignalfn(pidfn, SIGTERM);

	if (ret < 0) {
		upslog_with_errno(LOG_ERR, "Stopping %s failed", pidfn);
		exec_error++;
		return;
	}
}
开发者ID:JungleGenius,项目名称:nut,代码行数:38,代码来源:upsdrvctl.c

示例15: main

int main(int argc, char **argv)
{
	const char	*prog = xbasename(argv[0]);

	verbose = 1;		/* TODO: remove when done testing */

	/* normally we don't have stderr, so get this going to syslog early */
	open_syslog(prog);
	syslogbit_set();

	upsname = getenv("UPSNAME");
	notify_type = getenv("NOTIFYTYPE");

	if ((!upsname) || (!notify_type)) {
		printf("Error: UPSNAME and NOTIFYTYPE must be set.\n");
		printf("This program should only be run from upsmon.\n");
		exit(EXIT_FAILURE);
	}

	/* see if this matches anything in the config file */
	checkconf();

	exit(EXIT_SUCCESS);
}
开发者ID:AlexLov,项目名称:nut,代码行数:24,代码来源:upssched.c


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