您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xbasename函数代码示例

51自学网 2021-06-03 10:15:23
  C++
这篇教程C++ xbasename函数代码示例写得很实用,希望能帮到您。

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

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


示例2: fput_main

intfput_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,


示例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,


示例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,


示例5: set_default_pdf_filename

static voidset_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,


示例6: copydir

static voidcopydir( 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,


示例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. */intaugbname(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,


示例8: do_kanji

static voiddo_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,


示例9: kpathsea_db_insert

voidkpathsea_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,


示例10: main

intmain (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,


示例11: main

intmain (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,


示例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,


示例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,


示例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,


示例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,


示例16: main

int main (int argc, char **argv){	log_options_t logopt = LOG_OPTS_STDERR_ONLY;	slurm_ctl_conf_t *conf = NULL;	shares_response_msg_t resp;	log_init(xbasename(argv[0]), logopt, 0, NULL);	xfree(slurmctld_conf.priority_type);	//logopt.stderr_level += 5;	logopt.prefix_level = 1;	log_alter(logopt, 0, NULL);	print_fields_have_header = 0;	print_fields_parsable_print = PRINT_FIELDS_PARSABLE_ENDING;	conf = slurm_conf_lock();	/* force priority type to be multifactor */	xfree(conf->priority_type);	conf->priority_type = xstrdup("priority/multifactor");	conf->priority_flags = PRIORITY_FLAGS_FAIR_TREE;	/* force accounting type to be slurmdbd (It doesn't really talk	 * to any database, but needs this to work with fairshare	 * calculation). */	xfree(conf->accounting_storage_type);	conf->accounting_storage_type = xstrdup("accounting_storage/slurmdbd");	/* set up a known environment to test against.  Since we are	 * only concerned about the fairshare we won't look at the other	 * factors here. */	conf->priority_decay_hl = 1;	conf->priority_favor_small = 0;	conf->priority_max_age = conf->priority_decay_hl;	conf->priority_reset_period = 0;	conf->priority_weight_age = 0;	conf->priority_weight_fs = 10000;	conf->priority_weight_js = 0;	conf->priority_weight_part = 0;	conf->priority_weight_qos = 0;	slurm_conf_unlock();	/* we don't want to do any decay here so make the save state	 * to /dev/null */	xfree(slurmctld_conf.state_save_location);	slurmctld_conf.state_save_location = "/dev/null";	/* now set up the association tree */	_setup_assoc_list();	/* now set up the job list */	job_list = list_create(_list_delete_job);	/* now init the priorities of the associations */	if (slurm_priority_init() != SLURM_SUCCESS)		fatal("failed to initialize priority plugin");	/* on some systems that don't have multiple cores we need to	 * sleep to make sure the thread gets started. */	sleep(1);	memset(&resp, 0, sizeof(shares_response_msg_t));	resp.assoc_shares_list = assoc_mgr_get_shares(NULL, 0, NULL, NULL);	process(&resp, 0);	/* free memory */	if (slurm_priority_fini() != SLURM_SUCCESS)		fatal("failed to finalize priority plugin");	if (job_list)		list_destroy(job_list);	if (resp.assoc_shares_list)		list_destroy(resp.assoc_shares_list);	if (assoc_mgr_assoc_list)		list_destroy(assoc_mgr_assoc_list);	if (assoc_mgr_qos_list)		list_destroy(assoc_mgr_qos_list);	return 0;}
开发者ID:bingzhang,项目名称:slurm,代码行数:70,


示例17: main

int main(int argc, char *argv[]){	log_options_t logopt = LOG_OPTS_STDERR_ONLY;	job_desc_msg_t desc;	resource_allocation_response_msg_t *alloc;	time_t before, after;	allocation_msg_thread_t *msg_thr;	char **env = NULL;	int status = 0;	int retries = 0;	pid_t pid  = getpid();	pid_t tpgid = 0;	pid_t rc_pid = 0;	int i, rc = 0;	static char *msg = "Slurm job queue full, sleeping and retrying.";	slurm_allocation_callbacks_t callbacks;	log_init(xbasename(argv[0]), logopt, 0, NULL);	_set_exit_code();	if (spank_init_allocator() < 0) {		error("Failed to initialize plugin stack");		exit(error_exit);	}	/* Be sure to call spank_fini when salloc exits	 */	if (atexit((void (*) (void)) spank_fini) < 0)		error("Failed to register atexit handler for plugins: %m");	if (initialize_and_process_args(argc, argv) < 0) {		error("salloc parameter parsing");		exit(error_exit);	}	/* reinit log with new verbosity (if changed by command line) */	if (opt.verbose || opt.quiet) {		logopt.stderr_level += opt.verbose;		logopt.stderr_level -= opt.quiet;		logopt.prefix_level = 1;		log_alter(logopt, 0, NULL);	}	if (spank_init_post_opt() < 0) {		error("Plugin stack post-option processing failed");		exit(error_exit);	}	_set_spank_env();	_set_submit_dir_env();	if (opt.cwd && chdir(opt.cwd)) {		error("chdir(%s): %m", opt.cwd);		exit(error_exit);	}	if (opt.get_user_env_time >= 0) {		char *user = uid_to_string(opt.uid);		if (strcmp(user, "nobody") == 0) {			error("Invalid user id %u: %m", (uint32_t)opt.uid);			exit(error_exit);		}		env = env_array_user_default(user,					     opt.get_user_env_time,					     opt.get_user_env_mode);		xfree(user);		if (env == NULL)			exit(error_exit);    /* error already logged */		_set_rlimits(env);	}	/*	 * Job control for interactive salloc sessions: only if ...	 *	 * a) input is from a terminal (stdin has valid termios attributes),	 * b) controlling terminal exists (non-negative tpgid),	 * c) salloc is not run in allocation-only (--no-shell) mode,	 * NOTE: d and e below are configuration dependent	 * d) salloc runs in its own process group (true in interactive	 *    shells that support job control),	 * e) salloc has been configured at compile-time to support background	 *    execution and is not currently in the background process group.	 */	if (tcgetattr(STDIN_FILENO, &saved_tty_attributes) < 0) {		/*		 * Test existence of controlling terminal (tpgid > 0)		 * after first making sure stdin is not redirected.		 */	} else if ((tpgid = tcgetpgrp(STDIN_FILENO)) < 0) {		if (!opt.no_shell) {			error("no controlling terminal: please set --no-shell");			exit(error_exit);		}#ifdef SALLOC_RUN_FOREGROUND	} else if ((!opt.no_shell) && (pid == getpgrp())) {		if (tpgid == pid)			is_interactive = true;		while (tcgetpgrp(STDIN_FILENO) != pid) {			if (!is_interactive) {				error("Waiting for program to be placed in "				      "the foreground");//.........这里部分代码省略.........
开发者ID:adk9,项目名称:slurm,代码行数:101,


示例18: _parse_comp_file

static int _parse_comp_file(	char *file, step_update_request_msg_t *step_msg){	int i;	FILE *fd = fopen(file, "r");	char line[BUFFER_SIZE];	char *fptr;	int version;	char *update[MAX_RECORD_FIELDS+1];    /* End list with null entry and,						 possibly, more data than we						 expected */	enum {	UPDATE_STEP_VERSION,		UPDATE_STEP_EXTRA,		UPDATE_STEP_INBLOCKS,		UPDATE_STEP_OUTBLOCKS,		UPDATE_STEP_EXITCODE,		UPDATE_STEP_CPU_ALLOC,		UPDATE_STEP_START,		UPDATE_STEP_END,		UPDATE_STEP_USER_SEC,		UPDATE_STEP_SYS_SEC,		UPDATE_STEP_MAX_RSS,		UPDATE_STEP_UID,		UPDATE_STEP_STEPNAME,		UPDATE_STEP_VER1_LENGTH	};	if (fd == NULL) {		perror(file);		return SLURM_ERROR;	}	if (!fgets(line, BUFFER_SIZE, fd)) {		fprintf(stderr, "Empty step update completion file/n");		return SLURM_ERROR;	}	fptr = line;	/* break the record into NULL-terminated strings */	for (i = 0; i < MAX_RECORD_FIELDS; i++) {		update[i] = fptr;		fptr = strstr(fptr, " ");		if (fptr == NULL) {			fptr = strstr(update[i], "/n");			if (fptr)				*fptr = 0;			break;		} else			*fptr++ = 0;	}	if (i < MAX_RECORD_FIELDS)		i++;	update[i] = 0;	version = atoi(update[UPDATE_STEP_VERSION]);	switch (version) {	case 1:		if (i != UPDATE_STEP_VER1_LENGTH) {			fprintf(stderr,				"Bad step update completion file length/n");			return SLURM_ERROR;		}		step_msg->jobacct = jobacctinfo_create(NULL);		step_msg->exit_code = atoi(update[UPDATE_STEP_EXITCODE]);		step_msg->start_time = atoi(update[UPDATE_STEP_START]);		step_msg->end_time = atoi(update[UPDATE_STEP_END]);		step_msg->jobacct->user_cpu_sec =			atoi(update[UPDATE_STEP_USER_SEC]);		step_msg->jobacct->sys_cpu_sec =			atoi(update[UPDATE_STEP_SYS_SEC]);		step_msg->jobacct->min_cpu =			step_msg->jobacct->user_cpu_sec			+ step_msg->jobacct->sys_cpu_sec;		step_msg->jobacct->max_rss = atoi(update[UPDATE_STEP_MAX_RSS]);		step_msg->name =			xstrdup(xbasename(update[UPDATE_STEP_STEPNAME]));		break;	default:		fprintf(stderr, "Unsupported step update "			"completion file version: %d/n",			version);		return SLURM_ERROR;		break;	}	return SLURM_SUCCESS;}
开发者ID:A1ve5,项目名称:slurm,代码行数:89,


示例19: _log_init

/* * Initialize log with * prog = program name to tag error messages with * opt  = log_options_t specifying max log levels for syslog, stderr, and file * fac  = log facility for syslog (unused if syslog level == LOG_QUIET) * logfile = *        logfile name if logfile level > LOG_QUIET */static int_log_init(char *prog, log_options_t opt, log_facility_t fac, char *logfile ){	int rc = 0;	if (!log)  {		log = (log_t *)xmalloc(sizeof(log_t));		log->logfp = NULL;		log->argv0 = NULL;		log->buf   = NULL;		log->fbuf  = NULL;		log->fpfx  = NULL;		atfork_install_handlers();	}	if (prog) {		if (log->argv0)			xfree(log->argv0);		log->argv0 = xstrdup(xbasename(prog));	} else if (!log->argv0) {		const char *short_name = strrchr(default_name, '/');		if (short_name)			short_name++;		else			short_name = default_name;		log->argv0 = xstrdup(short_name);	}	if (!log->fpfx)		log->fpfx = xstrdup("");	log->opt = opt;	if (log->buf) {		cbuf_destroy(log->buf);		log->buf = NULL;	}	if (log->fbuf) {		cbuf_destroy(log->fbuf);		log->fbuf = NULL;	}	if (log->opt.buffered) {		log->buf  = cbuf_create(128, 8192);		log->fbuf = cbuf_create(128, 8192);	}	if (log->opt.syslog_level > LOG_LEVEL_QUIET)		log->facility = fac;	if (logfile && (log->opt.logfile_level > LOG_LEVEL_QUIET)) {		FILE *fp;		fp = safeopen(logfile, "a", SAFEOPEN_LINK_OK);		if (!fp) {			char *errmsg = NULL;			xslurm_strerrorcat(errmsg);			fprintf(stderr,				"%s: log_init(): Unable to open logfile"			        "`%s': %s/n", prog, logfile, errmsg);			xfree(errmsg);			rc = errno;			goto out;		}		if (log->logfp)			fclose(log->logfp); /* Ignore errors */		log->logfp = fp;	}	if (log->logfp) {		int fd;		if ((fd = fileno(log->logfp)) < 0)			log->logfp = NULL;		else			fd_set_close_on_exec(fd);	}	log->initialized = 1; out:	return rc;}
开发者ID:jimmycao,项目名称:slurm-test,代码行数:92,


示例20: main

intmain(int argc, char **argv){	int debug_level, sig, srun_fd;	struct sigaction sa;	log_options_t logopt = LOG_OPTS_STDERR_ONLY;	struct sockaddr_un ca;	unsigned int ca_len = sizeof(ca);	atexit(remove_listen_socket);	/* copied from srun */	debug_level = _slurm_debug_env_val();	logopt.stderr_level += debug_level;	log_init(xbasename(argv[0]), logopt, 0, NULL);	if (init_srun_argv(argc, argv)) {		fatal("failed to initialize arguments for running srun");	}	if ((cr_id = cr_init()) < 0) {		fatal("failed to initialize libcr: %s", cr_strerror(errno));	}	(void)cr_register_callback(cr_callback, NULL, CR_THREAD_CONTEXT);	/* forward signals. copied from cr_restart */	sa.sa_sigaction = signal_child;	sa.sa_flags = SA_RESTART | SA_NODEFER | SA_SIGINFO;	sigemptyset(&sa.sa_mask);	for (sig = 0;  sig < _NSIG; sig ++) {		if (sig == SIGSTOP ||		    sig == SIGKILL ||		    sig == SIGCHLD)			continue;		sigaction(sig, &sa, NULL);	}	sa.sa_sigaction = on_child_exit;	sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_NOCLDSTOP;	sigaction(SIGCHLD, &sa, NULL);	cr_enter_cs(cr_id); /* BEGIN CS: avoid race condition of whether srun is forked */	if ( fork_exec_srun() ) {		fatal("failed fork/exec/wait srun");	}	cr_leave_cs(cr_id); /* END CS */	while (1) {		pthread_mutex_lock(&step_launch_mutex);		while (step_launched) {			/* just avoid busy waiting */			pthread_cond_wait(&step_launch_cond,					  &step_launch_mutex);		}		pthread_mutex_unlock(&step_launch_mutex);		if (_wait_for_srun_connect() < 0)			continue;		cr_enter_cs(cr_id); /* BEGIN CS: checkpoint(callback) will be delayed */		srun_fd = accept(listen_fd, (struct sockaddr*)&ca, &ca_len);		if (srun_fd < 0) {			/* restarted before enter CS. socket will not be restored */			if (errno == EBADF) {				cr_leave_cs(cr_id);				continue;			} else {				fatal("failed to accept socket: %m");			}		}		_read_info_from_srun(srun_fd);		close(srun_fd);		step_launched = 1;		debug2("step launched");		cr_leave_cs(cr_id); /* END CS */	}	return 0;}
开发者ID:Xarthisius,项目名称:slurm,代码行数:82,


示例21: main

int main(int argc, char *argv[]){    opt_t opt;    int retval = 0;    const char *m;    /*     * Initialize.     */    err_init(xbasename(argv[0]));       /* init err package */    /*     *  If running setuid, fork a child to handle      *   all privileged operations and drop privs in this process.     */    privsep_init();    /*     * Seed options with default values:     */    opt_default(&opt, argv[0]);    /*     * Override defaults with environment     */    opt_env(&opt);    /*     * Process any options that need to be handled early:     */    opt_args_early(&opt, argc, argv);    /*     *  Load static or dynamic pdsh modules     */    mod_init();    /*     *  Allow module directory to be overridden, but not when     *   running as root or setuid. (This is mainly for testing...)     */    if (!(m = getenv ("PDSH_MODULE_DIR")) ||          getuid() == 0 ||          getuid() != geteuid())        m = pdsh_module_dir;    if (mod_load_modules(m, &opt) < 0)        errx("%p: Couldn't load any pdsh modules/n");    /*     * Handle options.     */    opt_args(&opt, argc, argv); /* override with command line           */    if (opt_verify(&opt)) {     /* verify options, print errors         */        /*         * Do the work.         */        if (opt.info_only)      /* display info only */            opt_list(&opt);        else if (pdsh_personality() == PCP && opt.pcp_server)             retval = (_pcp_remote_server (&opt) < 0);        else if (pdsh_personality() == PCP && opt.pcp_client)            retval = (_pcp_remote_client (&opt) < 0);        else if (pdsh_personality() == PCP || opt.cmd != NULL)            retval = dsh(&opt); /* single dsh/pcp command */        else                    /* prompt loop */            _interactive_dsh(&opt);    } else {        retval = 1;    }    mod_exit();     /*     * Clean up.     */    privsep_fini();    opt_free(&opt);             /* free heap storage in opt struct */    err_cleanup();    return retval;}
开发者ID:AdityaSarang,项目名称:pdsh,代码行数:82,


示例22: main

int main (int argc, char *argv[]){	char *prio_type = NULL;	int error_code = SLURM_SUCCESS;	priority_factors_request_msg_t req_msg;	priority_factors_response_msg_t *resp_msg = NULL;	log_options_t opts = LOG_OPTS_STDERR_ONLY ;	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);	}	if (working_cluster_rec) {		slurm_ctl_conf_info_msg_t  *slurm_ctl_conf_ptr;		error_code = slurm_load_ctl_conf((time_t) NULL,						  &slurm_ctl_conf_ptr);		if (error_code) {			slurm_perror ("slurm_load_ctl_conf error");			exit(error_code);		}		weight_age  = slurm_ctl_conf_ptr->priority_weight_age;		weight_fs   = slurm_ctl_conf_ptr->priority_weight_fs;		weight_js   = slurm_ctl_conf_ptr->priority_weight_js;		weight_part = slurm_ctl_conf_ptr->priority_weight_part;		weight_qos  = slurm_ctl_conf_ptr->priority_weight_qos;		weight_tres = slurm_ctl_conf_ptr->priority_weight_tres;		prio_type   = xstrdup(slurm_ctl_conf_ptr->priority_type);		slurm_free_ctl_conf(slurm_ctl_conf_ptr);	} else {		weight_age  = slurm_get_priority_weight_age();		weight_fs   = slurm_get_priority_weight_fairshare();		weight_js   = slurm_get_priority_weight_job_size();		weight_part = slurm_get_priority_weight_partition();		weight_qos  = slurm_get_priority_weight_qos();		weight_tres = slurm_get_priority_weight_tres();		prio_type   = slurm_get_priority_type();	}	/* Check to see if we are running a supported accounting plugin */	if (xstrcasecmp(prio_type, "priority/basic") == 0) {		fprintf (stderr, "You are not running a supported "			 "priority plugin/n(%s)./n"			 "Only 'priority/multifactor' is supported./n",			 prio_type);		exit(1);	}	xfree(prio_type);	memset(&req_msg, 0, sizeof(priority_factors_request_msg_t));	if (params.jobs)		req_msg.job_id_list = params.job_list;	else		req_msg.job_id_list = NULL;	if (params.users)		req_msg.uid_list = params.user_list;	else		req_msg.uid_list = NULL;	error_code = _get_info(&req_msg, &resp_msg);	if (error_code) {		slurm_perror("Couldn't get priority factors from controller");		exit(error_code);	}	if (params.format == NULL) {		if (params.normalized) {			if (params.long_list)				params.format = "%.15i %.8u %10y %10a %10f "					"%10j %10p %10q %20t";			else{				params.format = xstrdup("%.15i");				if (params.users)					xstrcat(params.format, " %.8u");				xstrcat(params.format, " %10y");				if (weight_age)					xstrcat(params.format, " %10a");				if (weight_fs)					xstrcat(params.format, " %10f");				if (weight_js)					xstrcat(params.format, " %10j");				if (weight_part)					xstrcat(params.format, " %10p");				if (weight_qos)					xstrcat(params.format, " %10q");				if (weight_tres)					xstrcat(params.format, " %20t");			}		} else {			if (params.long_list)				params.format = "%.15i %.8u %.10Y %.10A %.10F "//.........这里部分代码省略.........
开发者ID:A1ve5,项目名称:slurm,代码行数:101,


示例23: main

intmain(int argc, char **argv){    int onlydir, dodir, dolink, dorelsymlink, dotimes, opt, len, lplen, tdlen, bnlen, exists, fromfd, tofd, cc, wc;    mode_t mode = 0755;    char *linkprefix, *owner, *group, *cp, *cwd, *todir, *toname, *name, *base, *linkname, *bp, buf[BUFSIZ];    uid_t uid;    gid_t gid;    struct stat sb, tosb;    struct utimbuf utb;    program = argv[0];    cwd = linkname = linkprefix = owner = group = 0;    onlydir = dodir = dolink = dorelsymlink = dotimes = lplen = 0;    while ((opt = getopt(argc, argv, "C:DdlL:Rm:o:g:t")) != EOF) {	switch (opt) {	  case 'C':	    cwd = optarg;	    break;	  case 'D':	    onlydir = 1;	    break;	  case 'd':	    dodir = 1;	    break;	  case 'l':	    dolink = 1;	    break;	  case 'L':	    linkprefix = optarg;	    lplen = strlen(linkprefix);	    dolink = 1;	    break;	  case 'R':	    dolink = dorelsymlink = 1;	    break;	  case 'm':	    mode = strtoul(optarg, &cp, 8);	    if (mode == 0 && cp == optarg)		usage();	    break;	  case 'o':	    owner = optarg;	    break;	  case 'g':	    group = optarg;	    break;	  case 't':	    dotimes = 1;	    break;	  default:	    usage();	}    }    argc -= optind;    argv += optind;    if (argc < 2 - onlydir)	usage();    todir = argv[argc-1];    if ((stat(todir, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&	mkdirs(todir, 0777) < 0) {	fail("cannot make directory %s", todir);    }    if (onlydir)	return 0;    if (!cwd) {#ifdef GETCWD_CAN_MALLOC	cwd = getcwd(0, PATH_MAX);#else	cwd = malloc(PATH_MAX + 1);	cwd = getcwd(cwd, PATH_MAX);#endif    }    xchdir(todir);#ifdef GETCWD_CAN_MALLOC    todir = getcwd(0, PATH_MAX);#else    todir = malloc(PATH_MAX + 1);    todir = getcwd(todir, PATH_MAX);#endif    tdlen = strlen(todir);    xchdir(cwd);    tdlen = strlen(todir);    uid = owner ? touid(owner) : -1;    gid = group ? togid(group) : -1;    while (--argc > 0) {	name = *argv++;	len = strlen(name);	base = xbasename(name);	bnlen = strlen(base);	toname = (char*)xmalloc(tdlen + 1 + bnlen + 1);	sprintf(toname, "%s/%s", todir, base);	exists = (lstat(toname, &tosb) == 0);//.........这里部分代码省略.........
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.external,代码行数:101,


示例24: _sched_log_init

/* * Initialize scheduler log with * prog = program name to tag error messages with * opt  = log_options_t specifying max log levels for syslog, stderr, and file * fac  = log facility for syslog (unused if syslog level == LOG_QUIET) * logfile = logfile name if logfile level > LOG_QUIET */static int_sched_log_init(char *prog, log_options_t opt, log_facility_t fac, 		char *logfile){	int rc = 0;	if (!sched_log) {		sched_log = (log_t *)xmalloc(sizeof(log_t));		atfork_install_handlers();	}	if (prog) {		xfree(sched_log->argv0);		sched_log->argv0 = xstrdup(xbasename(prog));	} else if (!sched_log->argv0) {		const char *short_name;		short_name = strrchr((const char *) default_name, '/');		if (short_name) 			short_name++;		else			short_name = default_name;		sched_log->argv0 = xstrdup(short_name);	}	if (!sched_log->fpfx)		sched_log->fpfx = xstrdup("");	sched_log->opt = opt;	if (sched_log->buf) {		cbuf_destroy(sched_log->buf);		sched_log->buf = NULL;	}	if (sched_log->fbuf) {		cbuf_destroy(sched_log->fbuf);		sched_log->fbuf = NULL;	}	if (sched_log->opt.buffered) {		sched_log->buf  = cbuf_create(128, 8192);		sched_log->fbuf = cbuf_create(128, 8192);	}	if (sched_log->opt.syslog_level > LOG_LEVEL_QUIET)		sched_log->facility = fac;	if (logfile) {		FILE *fp;		fp = safeopen(logfile, "a", SAFEOPEN_LINK_OK);		if (!fp) {			rc = errno;			goto out;		}		if (sched_log->logfp)			fclose(sched_log->logfp); /* Ignore errors */		sched_log->logfp = fp;	}	if (sched_log->logfp) {		int fd;		if ((fd = fileno(sched_log->logfp)) < 0)			sched_log->logfp = NULL;		else			fd_set_close_on_exec(fd);	}	sched_log->initialized = 1; out:	return rc;}
开发者ID:jimmycao,项目名称:slurm-test,代码行数:81,


示例25: main

int main(int argc, char **argv){	int	interval = 30, i;	const char	*prog = xbasename(argv[0]);	time_t	now, nextpoll = 0;	const char	*user = NULL;	struct passwd	*new_uid = NULL;	const char	*pidfilebase = prog;	logformat = DEFAULT_LOGFORMAT;	user = RUN_AS_USER;	printf("Network UPS Tools %s %s/n", prog, UPS_VERSION);	 while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:")) != -1) {		switch(i) {			case 'h':				help(prog);				break;			case 's':				monhost = optarg;				break;			case 'l':				logfn = optarg;				break;			case 'i':				interval = atoi(optarg);				break;			case 'f':				logformat = optarg;				break;			case 'u':				user = optarg;				break;			case 'V':				exit(EXIT_SUCCESS);			case 'p':				pidfilebase = optarg;				break;		}	}	argc -= optind;	argv += optind;	/* not enough args for the old way? */	if ((argc == 1) || (argc == 2))		help(prog);	/* see if it's being called in the old style - 3 or 4 args */	/* <system> <logfn> <interval> [<format>] */	if (argc >= 3) {		monhost = argv[0];		logfn = argv[1];		interval = atoi(argv[2]);	}	if (argc >= 4) {		/* read out the remaining argv entries to the format string */		logformat = xmalloc(LARGEBUF);		memset(logformat, '/0', LARGEBUF);		for (i = 3; i < argc; i++)			snprintfcat(logformat, LARGEBUF, "%s ", argv[i]);	}	if (!monhost)		fatalx(EXIT_FAILURE, "No UPS defined for monitoring - use -s <system>");	if (!logfn)		fatalx(EXIT_FAILURE, "No filename defined for logging - use -l <file>");	/* shouldn't happen */	if (!logformat)		fatalx(EXIT_FAILURE, "No format defined - but this should be impossible");	printf("logging status of %s to %s (%is intervals)/n", 		monhost, logfn, interval);	if (upscli_splitname(monhost, &upsname, &hostname, &port) != 0) {		fatalx(EXIT_FAILURE, "Error: invalid UPS definition.  Required format: upsname[@hostname[:port]]/n");	}	if (upscli_connect(&ups, hostname, port, UPSCLI_CONN_TRYSSL) < 0)		fprintf(stderr, "Warning: initial connect failed: %s/n", 			upscli_strerror(&ups));	if (strcmp(logfn, "-") == 0)		logfile = stdout;	else//.........这里部分代码省略.........
开发者ID:alezz,项目名称:nut,代码行数:101,



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


C++ xbt_assert函数代码示例
C++ xasprintf函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。