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


C++ xstrcmp函数代码示例

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


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

示例1: gg_session_handler_search50

/*
 * gg_session_handler_search50()
 *
 * zajmuje siê obs³ug± wyniku przeszukiwania katalogu publicznego.
 *
 *  - s - sesja
 *  - e - opis zdarzenia
 */
void gg_session_handler_search50(session_t *s, struct gg_event *e)
{
	gg_private_t *g = session_private_get(s);
	gg_pubdir50_t res = e->event.pubdir50;
	int i, count, all = 0;
	list_t l;
	uin_t last_uin = 0;

	if (!g)
		return;

	if ((count = gg_pubdir50_count(res)) < 1) {
		print("search_not_found");
		return;
	}

	debug_function("gg_session_handler_search50() handle_search50, count = %d\n", gg_pubdir50_count(res));

	for (l = g->searches; l; l = l->next) {
		gg_pubdir50_t req = l->data;

		if (gg_pubdir50_seq(req) == gg_pubdir50_seq(res)) {
			all = 1;
			break;
		}
	}

	for (i = 0; i < count; i++) {
		const char *uin		= gg_pubdir50_get(res, i, "fmnumber");
		const char *__firstname = gg_pubdir50_get(res, i, "firstname");
		const char *__lastname	= gg_pubdir50_get(res, i, "lastname");
		const char *__nickname	= gg_pubdir50_get(res, i, "nickname");
		const char *__fmstatus	= gg_pubdir50_get(res, i, "fmstatus");
		const char *__birthyear = gg_pubdir50_get(res, i, "birthyear");
		const char *__city	= gg_pubdir50_get(res, i, "city");

		char *firstname		= gg_to_core_dup(s, __firstname);
		char *lastname		= gg_to_core_dup(s, __lastname);
		char *nickname		= gg_to_core_dup(s, __nickname);
		char *city		= gg_to_core_dup(s, __city);
		int status		= (__fmstatus)	? atoi(__fmstatus) : GG_STATUS_NOT_AVAIL;
		const char *birthyear	= (__birthyear && xstrcmp(__birthyear, "0")) ? __birthyear : NULL;

		char *name, *active, *gender;
		const char *target = NULL;

		if (count == 1 && !all) {
			xfree(last_search_first_name);
			xfree(last_search_last_name);
			xfree(last_search_nickname);
			xfree(last_search_uid);
			last_search_first_name	= xstrdup(firstname);
			last_search_last_name	= xstrdup(lastname);
			last_search_nickname	= xstrdup(nickname);
			last_search_uid		= saprintf("gg:%s", uin);
		}

		name = saprintf(
			("%s %s"),
					firstname ? firstname : (""), 
					lastname ? lastname : (""));

#define __format(x) ((count == 1 && !all) ? "search_results_single" x : "search_results_multi" x)
		{
			const char *fvalue;
			switch (status) {
				case GG_STATUS_AVAIL:
				case GG_STATUS_AVAIL_DESCR:
					fvalue = format_find(__format("_avail"));
					break;
				case GG_STATUS_BUSY:
				case GG_STATUS_BUSY_DESCR:
					fvalue = format_find(__format("_away"));
					break;
				default:
					fvalue = format_find(__format("_notavail"));
			}
			active = format_string(fvalue, (__firstname) ? __firstname : nickname);
		}
		gender = format_string(format_find(__format("_unknown")), "");

			/* XXX: why do we _exactly_ use it here? can't we just always
			 *	define target and thus display result in right conversation window? */
		for (l = autofinds; l; l = l->next) {
			char *d = (char *) l->data;
		
			if (!xstrcasecmp(d + 3, uin)) {
				target = d;
				break;
			}
		}
		
//.........这里部分代码省略.........
开发者ID:11mariom,项目名称:ekg2,代码行数:101,代码来源:pubdir50.c

示例2: _create_bb_info_list

static List _create_bb_info_list(burst_buffer_info_msg_t *bb_info_ptr)
{
	static List info_list = NULL;
	List last_list = NULL;
	ListIterator last_list_itr = NULL;
	int i, j, pos = 0;
	static burst_buffer_info_msg_t *last_bb_info_ptr = NULL;
	sview_bb_info_t *sview_bb_info_ptr = NULL;
	burst_buffer_info_t *bb_ptr;
	burst_buffer_resv_t *bb_resv_ptr = NULL;
	char bb_name_id[32] = "";

	if (info_list && (bb_info_ptr == last_bb_info_ptr))
		return info_list;

	last_bb_info_ptr = bb_info_ptr;
	if (info_list)
		last_list = info_list;
	info_list = list_create(_bb_info_list_del);

	for (i = 0, bb_ptr = bb_info_ptr->burst_buffer_array;
	     i < bb_info_ptr->record_count; i++, bb_ptr++) {

		for (j = 0, bb_resv_ptr = bb_ptr->burst_buffer_resv_ptr;
		     j < bb_ptr->buffer_count; j++, bb_resv_ptr++) {

			/* Find any existing record for this burst buffer */
			if (last_list) {
				last_list_itr = list_iterator_create(last_list);
				while ((sview_bb_info_ptr =
					list_next(last_list_itr))) {
					if (bb_resv_ptr->job_id &&
					    (bb_resv_ptr->job_id != 
					     sview_bb_info_ptr->bb_ptr->job_id))
						continue;
					if (bb_resv_ptr->name &&
					    xstrcmp(sview_bb_info_ptr->bb_name,
						    bb_resv_ptr->name))
						continue;
					if (xstrcmp(sview_bb_info_ptr->plugin,
						    bb_ptr->name))
						continue;
					list_remove(last_list_itr);
					_bb_info_free(sview_bb_info_ptr);
					break;
				}
				list_iterator_destroy(last_list_itr);
			} else {
				sview_bb_info_ptr = NULL;
			}

			if (bb_resv_ptr->name) {
				strlcpy(bb_name_id, bb_resv_ptr->name,
					sizeof(bb_name_id));
			} else if (bb_resv_ptr->array_task_id == NO_VAL) {
				convert_num_unit(bb_resv_ptr->job_id,
						 bb_name_id,
						 sizeof(bb_name_id),
						 UNIT_NONE, NO_VAL,
						 working_sview_config.
						 convert_flags);
			} else {
				snprintf(bb_name_id, sizeof(bb_name_id),
					 "%u_%u(%u)",
					 bb_resv_ptr->array_job_id,
					 bb_resv_ptr->array_task_id,
					 bb_resv_ptr->job_id);
			}

			if (!sview_bb_info_ptr) {	/* Need new record */
				sview_bb_info_ptr =
					xmalloc(sizeof(sview_bb_info_t));
			}
			sview_bb_info_ptr->bb_ptr = bb_resv_ptr;
			sview_bb_info_ptr->bb_name = xstrdup(bb_name_id);
			strcpy(bb_name_id, "");	/* Clear bb_name_id */
			sview_bb_info_ptr->color_inx = pos % sview_colors_cnt;
			sview_bb_info_ptr->plugin = xstrdup(bb_ptr->name);
			sview_bb_info_ptr->pos = pos++;
			list_append(info_list, sview_bb_info_ptr);
		}
	}

	FREE_NULL_LIST(last_list);
	return info_list;
}
开发者ID:A1ve5,项目名称:slurm,代码行数:86,代码来源:bb_info.c

示例3: COMMAND

static COMMAND(xmsg_msg)
{
	char fn[sizeof(XMSG_TMPFILE_PATH)];
	int fd;
	char *msg = (char*) params[1];
	const char *uid;
	int fs;
	int n;
	const char *msgcmd = session_get(session, "send_cmd");
	char *msgx = NULL, *mymsg;
	
	if (!(uid = get_uid(session, target))) {
		printq("invalid_session");
		return -1;
	}

	if (!msgcmd || *msgcmd == '\0') {
		printq("xmsg_nosendcmd", session_name(session));
		return -1;
	}
	
	xstrcpy(fn, XMSG_TMPFILE_PATH);
	
	fd = mkstemp(fn);
	if (fd == -1)
		xerrn("Unable to create temp file");
	{
		const char *charset = session_get(session, "charset");

		if (charset)
			msgx = ekg_convert_string(msg, NULL, charset);
		mymsg = (msgx ? msgx : msg);
	}
	fs = xstrlen(mymsg);

	while (fs > 0) {
		if ((n = write(fd, mymsg, fs)) == -1) {
			unlink(fn);
			close(fd);
			xfree(msgx);
			xerrn("Unable to write message into temp file");
		}
		fs -= n;
		mymsg += n;
	}

	xfree(msgx);	
	close(fd);
	if ((command_exec_format(NULL, session, 1, "!^%s \"%s\" \"%s\"", msgcmd, target+XMSG_UID_DIROFFSET, fn)))
		xerr("msgcmd exec failed");
	
	{
		char **rcpts	= xcalloc(2, sizeof(char *));
		int class	= (xstrcmp(name, "chat") ? EKG_MSGCLASS_SENT : EKG_MSGCLASS_SENT_CHAT);

		rcpts[0]	= xstrdup(uid);
		rcpts[1]	= NULL;

		protocol_message_emit(session, session->uid, rcpts, params[1], NULL, time(NULL), class, NULL, EKG_NO_BEEP, 0);

		array_free(rcpts);
	}
			
	return 0;
}
开发者ID:dmilith,项目名称:ekg2-bsd,代码行数:65,代码来源:xmsg.c

示例4: _sort_step_by_node_list

static int _sort_step_by_node_list(void *void1, void *void2)
{
	int diff = 0;
	job_step_info_t *step1;
	job_step_info_t *step2;

	hostlist_t hostlist1, hostlist2;
	char *val1, *val2;
	char *ptr1, *ptr2;
#if	PURE_ALPHA_SORT == 0
	int inx;
#endif

	_get_step_info_from_void(&step1, &step2, void1, void2);

	hostlist1 = hostlist_create(step1->nodes);
	hostlist_sort(hostlist1);
	val1 = hostlist_shift(hostlist1);
	if (val1)
		ptr1 = val1;
	else
		ptr1 = "";
	hostlist_destroy(hostlist1);

	hostlist2 = hostlist_create(step2->nodes);
	hostlist_sort(hostlist2);
	val2 = hostlist_shift(hostlist2);
	if (val2)
		ptr2 = val2;
	else
		ptr2 = "";
	hostlist_destroy(hostlist2);

#if	PURE_ALPHA_SORT
	diff = xstrcmp(ptr1, ptr2);
#else
	for (inx = 0; ; inx++) {
		if (ptr1[inx] == ptr2[inx]) {
			if (ptr1[inx] == '\0')
				break;
			continue;
		}
		if ((isdigit((int)ptr1[inx])) &&
		    (isdigit((int)ptr2[inx]))) {
			int num1, num2;
			num1 = atoi(ptr1 + inx);
			num2 = atoi(ptr2 + inx);
			diff = num1 - num2;
		} else
			diff = xstrcmp(ptr1, ptr2);
		break;
	}
#endif
	if (val1)
		free(val1);
	if (val2)
		free(val2);

	if (reverse_order)
		diff = -diff;
	return diff;
}
开发者ID:HPCNow,项目名称:slurm,代码行数:62,代码来源:sort.c

示例5: pthread_setcancelstate

/* _background_rpc_mgr - Read and process incoming RPCs to the background
 *	controller (that's us) */
static void *_background_rpc_mgr(void *no_data)
{
	slurm_fd_t newsockfd;
	slurm_fd_t sockfd;
	slurm_addr_t cli_addr;
	slurm_msg_t *msg = NULL;
	int error_code;
	char* node_addr = NULL;

	/* Read configuration only */
	slurmctld_lock_t config_read_lock = {
		READ_LOCK, NO_LOCK, NO_LOCK, NO_LOCK };
	int sigarray[] = {SIGUSR1, 0};

	(void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
	(void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
	debug3("_background_rpc_mgr pid = %lu", (unsigned long) getpid());

	/* initialize port for RPCs */
	lock_slurmctld(config_read_lock);

	/* set node_addr to bind to (NULL means any) */
	if ((xstrcmp(slurmctld_conf.backup_controller,
		     slurmctld_conf.backup_addr) != 0)) {
		node_addr = slurmctld_conf.backup_addr ;
	}

	if ((sockfd =
	     slurm_init_msg_engine_addrname_port(node_addr,
						 slurmctld_conf.
						 slurmctld_port))
	    == SLURM_SOCKET_ERROR)
		fatal("slurm_init_msg_engine_addrname_port error %m");
	unlock_slurmctld(config_read_lock);

	/* Prepare to catch SIGUSR1 to interrupt accept().
	 * This signal is generated by the slurmctld signal
	 * handler thread upon receipt of SIGABRT, SIGINT,
	 * or SIGTERM. That thread does all processing of
	 * all signals. */
	xsignal(SIGUSR1, _sig_handler);
	xsignal_unblock(sigarray);

	/*
	 * Process incoming RPCs indefinitely
	 */
	while (slurmctld_config.shutdown_time == 0) {
		/* accept needed for stream implementation
		 * is a no-op in message implementation that just passes
		 * sockfd to newsockfd */
		if ((newsockfd = slurm_accept_msg_conn(sockfd, &cli_addr))
		    == SLURM_SOCKET_ERROR) {
			if (errno != EINTR)
				error("slurm_accept_msg_conn: %m");
			continue;
		}

		msg = xmalloc(sizeof(slurm_msg_t));
		slurm_msg_t_init(msg);
		if (slurm_receive_msg(newsockfd, msg, 0) != 0)
			error("slurm_receive_msg: %m");

		error_code = _background_process_msg(msg);
		if ((error_code == SLURM_SUCCESS)			&&
		    (msg->msg_type == REQUEST_SHUTDOWN_IMMEDIATE)	&&
		    (slurmctld_config.shutdown_time == 0))
			slurmctld_config.shutdown_time = time(NULL);

		slurm_free_msg(msg);

		slurm_close(newsockfd);	/* close new socket */
	}

	debug3("_background_rpc_mgr shutting down");
	slurm_close(sockfd);	/* close the main socket */
	pthread_exit((void *) 0);
	return NULL;
}
开发者ID:HDOD,项目名称:slurm,代码行数:80,代码来源:backup.c

示例6: slurm_sprint_job_info


//.........这里部分代码省略.........
		gres_last = "";
		/* tmp1[] stores the current cpu(s) allocated */
		tmp2[0] = '\0';	/* stores last cpu(s) allocated */
		for (rel_node_inx=0; rel_node_inx < job_resrcs->nhosts;
		     rel_node_inx++) {

			if (sock_reps >=
			    job_resrcs->sock_core_rep_count[sock_inx]) {
				sock_inx++;
				sock_reps = 0;
			}
			sock_reps++;

			bit_reps = job_resrcs->sockets_per_node[sock_inx] *
				   job_resrcs->cores_per_socket[sock_inx];
			host = hostlist_shift(hl);
			threads = _threads_per_core(host);
			cpu_bitmap = bit_alloc(bit_reps * threads);
			for (j = 0; j < bit_reps; j++) {
				if (bit_test(job_resrcs->core_bitmap, bit_inx)){
					for (k = 0; k < threads; k++)
						bit_set(cpu_bitmap,
							(j * threads) + k);
				}
				bit_inx++;
			}
			bit_fmt(tmp1, sizeof(tmp1), cpu_bitmap);
			FREE_NULL_BITMAP(cpu_bitmap);
			/*
			 * If the allocation values for this host are not the
			 * same as the last host, print the report of the last
			 * group of hosts that had identical allocation values.
			 */
			if (xstrcmp(tmp1, tmp2) ||
			    ((rel_node_inx < job_ptr->gres_detail_cnt) &&
			     xstrcmp(job_ptr->gres_detail_str[rel_node_inx],
				     gres_last)) ||
			    (last_mem_alloc_ptr != job_resrcs->memory_allocated) ||
			    (job_resrcs->memory_allocated &&
			     (last_mem_alloc !=
			      job_resrcs->memory_allocated[rel_node_inx]))) {
				if (hostlist_count(hl_last)) {
					last_hosts =
						hostlist_ranged_string_xmalloc(
						hl_last);
					xstrfmtcat(out,
						   "  Nodes=%s CPU_IDs=%s "
						   "Mem=%"PRIu64" GRES_IDX=%s",
						   last_hosts, tmp2,
						   last_mem_alloc_ptr ?
						   last_mem_alloc : 0,
						    gres_last);
					xfree(last_hosts);
					xstrcat(out, line_end);

					hostlist_destroy(hl_last);
					hl_last = hostlist_create(NULL);
				}
				strcpy(tmp2, tmp1);
				if (rel_node_inx < job_ptr->gres_detail_cnt) {
					gres_last = job_ptr->
						    gres_detail_str[rel_node_inx];
				} else {
					gres_last = "";
				}
				last_mem_alloc_ptr = job_resrcs->memory_allocated;
开发者ID:fafik23,项目名称:slurm,代码行数:67,代码来源:job_info.c

示例7: launch_common_set_stdio_fds

extern void launch_common_set_stdio_fds(srun_job_t *job,
					slurm_step_io_fds_t *cio_fds,
					slurm_opt_t *opt_local)
{
	srun_opt_t *srun_opt = opt_local->srun_opt;
	bool err_shares_out = false;
	int file_flags;
	xassert(srun_opt);

	if (srun_opt->open_mode == OPEN_MODE_APPEND)
		file_flags = O_CREAT|O_WRONLY|O_APPEND;
	else if (srun_opt->open_mode == OPEN_MODE_TRUNCATE)
		file_flags = O_CREAT|O_WRONLY|O_APPEND|O_TRUNC;
	else {
		slurm_ctl_conf_t *conf;
		conf = slurm_conf_lock();
		if (conf->job_file_append)
			file_flags = O_CREAT|O_WRONLY|O_APPEND;
		else
			file_flags = O_CREAT|O_WRONLY|O_APPEND|O_TRUNC;
		slurm_conf_unlock();
	}

	/*
	 * create stdin file descriptor
	 */
	if (_is_local_file(job->ifname)) {
		if ((job->ifname->name == NULL) ||
		    (job->ifname->taskid != -1)) {
			cio_fds->input.fd = STDIN_FILENO;
		} else {
			cio_fds->input.fd = open(job->ifname->name, O_RDONLY);
			if (cio_fds->input.fd == -1) {
				error("Could not open stdin file: %m");
				exit(error_exit);
			}
		}
		if (job->ifname->type == IO_ONE) {
			cio_fds->input.taskid = job->ifname->taskid;
			cio_fds->input.nodeid = slurm_step_layout_host_id(
				launch_common_get_slurm_step_layout(job),
				job->ifname->taskid);
		}
	}

	/*
	 * create stdout file descriptor
	 */
	if (_is_local_file(job->ofname)) {
		if ((job->ofname->name == NULL) ||
		    (job->ofname->taskid != -1)) {
			cio_fds->out.fd = STDOUT_FILENO;
		} else {
			cio_fds->out.fd = open(job->ofname->name,
					       file_flags, 0644);
			if (cio_fds->out.fd == -1) {
				error("Could not open stdout file: %m");
				exit(error_exit);
			}
		}
		if (job->ofname->name != NULL
		    && job->efname->name != NULL
		    && !xstrcmp(job->ofname->name, job->efname->name)) {
			err_shares_out = true;
		}
	}

	/*
	 * create seperate stderr file descriptor only if stderr is not sharing
	 * the stdout file descriptor
	 */
	if (err_shares_out) {
		debug3("stdout and stderr sharing a file");
		cio_fds->err.fd = cio_fds->out.fd;
		cio_fds->err.taskid = cio_fds->out.taskid;
	} else if (_is_local_file(job->efname)) {
		if ((job->efname->name == NULL) ||
		    (job->efname->taskid != -1)) {
			cio_fds->err.fd = STDERR_FILENO;
		} else {
			cio_fds->err.fd = open(job->efname->name,
					       file_flags, 0644);
			if (cio_fds->err.fd == -1) {
				error("Could not open stderr file: %m");
				exit(error_exit);
			}
		}
	}
}
开发者ID:chrisdukey,项目名称:slurm,代码行数:89,代码来源:launch.c

示例8: load_usual_group

static void
load_usual_group(const xmlNode *group, form_element_t *parent)
{
    const xmlNode *p = find_by_path(group, "Properties/Group")->children;

    int grouping = xstrcmp(p->content, "Horizontal") == 0
            ? GROUPING_HORIZONTAL
            : GROUPING_VERTICAL
    ;
    bool show_title = true;
    p = find_by_path(group, "Properties/ShowTitle");
    if (xstrcmp(children_content(p), "false") == 0)
        show_title = false;
    const xmlChar *title = entry_title_ex(group, false);

    int repr = REPRESENTATION_NONE;

    p = find_by_path(group, "Properties/Representation");
    const xmlChar *s = children_content(p);
    if (xstrcmp(s, "StrongSeparation") == 0)
        repr = REPRESENTATION_STRONG;

    form_element_t G;

    G.widget = grouping == GROUPING_HORIZONTAL
        ? gtk_hbox_new(false, repr == REPRESENTATION_STRONG ? 2 : 0)
        : gtk_vbox_new(false, repr == REPRESENTATION_STRONG ? 2 : 0)
    ;
    G.box = true;

    p = find_by_path(group, "ContainedItems");
    if (p) {

        int count_table;
        const xmlNode *cur_node = p->children;

        while (cur_node) {

            count_table = 0;

            if (grouping == GROUPING_VERTICAL) {
                const xmlNode *n = cur_node;
                while (n) {
                    if (is_oftype(n, "Text") || is_oftype(n, "Input")) {
                        ++count_table;
                        n = n->next;

                        while (n && n->type != XML_ELEMENT_NODE)
                            n = n->next;

                        if (!n)
                            break;
                    } else
                        break;
                }
            }

            if ((count_table > 1) && (grouping == GROUPING_VERTICAL)) {

                form_element_t T;
                T.widget = gtk_table_new(count_table, 2, false);
                T.table_index = 0;

                container_add(&G, T.widget);

                while (count_table--) {
                    if (is_oftype(cur_node, "Text") || is_oftype(cur_node, "Input")) {
                        load_text_entry(cur_node, &T, true);
                        ++T.table_index;
                    }
                    cur_node = cur_node->next;
                    while (cur_node && cur_node->type != XML_ELEMENT_NODE)
                        cur_node = cur_node->next;
                }
            }
            else {
                load_form_element(cur_node, &G);
                cur_node = cur_node->next;
            }
        }

    }

    if (repr == REPRESENTATION_STRONG) {
        GtkWidget *widget = gtk_frame_new("");

        if (show_title)
            gtk_frame_set_label(GTK_FRAME(widget), GTK_CHAR(title));

        gtk_container_add(GTK_CONTAINER(widget), G.widget);
        container_add(parent, widget);
    } else
        container_add(parent, G.widget);
}
开发者ID:dmpas,项目名称:e1c83-form-gtk,代码行数:94,代码来源:main.c

示例9: load_text_entry

static void
load_text_entry(const xmlNode *text, form_element_t *parent, bool in_table)
{
    bool is_edit = true;
    const xmlNode *p;

    p = find_by_path(text, "Properties/Type");
    if (p)
        if (xstrcmp(children_content(p), "LabelField") == 0)
            is_edit = false;

    const xmlChar *label = entry_title_ex(text, is_edit);
    p = find_by_path(text, "Properties/TitleLocation");

    int title_loc = TITLE_LOCATION_LEFT;

    {
        const xmlChar *xc_title_loc = children_content(p);
        if (xc_title_loc) {
            if (xstrcmp(xc_title_loc, "None") == 0)
                title_loc = TITLE_LOCATION_NONE;
            if (xstrcmp(xc_title_loc, "Right") == 0)
                title_loc = TITLE_LOCATION_RIGHT;
        }
    }

    form_element_t E;
    E.box = false;

    if (label && title_loc != TITLE_LOCATION_NONE) {
        E.widget = gtk_hbox_new(false, 0);

        GtkWidget *w_label = gtk_label_new(GTK_CHAR(label));
        GtkWidget *w_edit = is_edit
            ? gtk_entry_new()
            : gtk_label_new("...")
        ;

        p = find_by_path(text, "Properties/HeaderHorizontalAlign");
        if (p)
            justify_element(w_label, p);

        if (!is_edit) {
            p = find_by_path(text, "Properties/HorizontalAlign");
            if (p)
                justify_element(w_edit, p);
        }

        if (in_table) {
            gtk_table_attach(GTK_TABLE(parent->widget),
                    w_label,
                    0, 1, parent->table_index + 1, parent->table_index + 2,
                    GTK_FILL, 0,
                    0, 0
            );
            gtk_table_attach(GTK_TABLE(parent->widget),
                    w_edit,
                    1, 2, parent->table_index + 1, parent->table_index + 2,
                    GTK_EXPAND | GTK_FILL, 0,
                    0, 0
            );
        } else {
            if (title_loc == TITLE_LOCATION_LEFT)
                gtk_box_pack_start(GTK_BOX(E.widget), w_label, false, false, 0);

            gtk_box_pack_start(GTK_BOX(E.widget), w_edit, true, true, 0);

            if (title_loc == TITLE_LOCATION_RIGHT)
                gtk_box_pack_start(GTK_BOX(E.widget), w_label, false, false, 0);

            container_add(parent, E.widget);
        }

    } else {
        if (is_edit)
            E.widget = gtk_entry_new();
        else {
            E.widget = gtk_label_new(GTK_CHAR(label));

            p = find_by_path(text, "Properties/HorizontalAlign");
            if (p)
                justify_element(E.widget, p);
        }

        if (in_table) {
            gtk_table_attach(GTK_TABLE(parent->widget),
                    E.widget,
                    1, 2, parent->table_index + 1, parent->table_index + 2,
                    GTK_EXPAND | GTK_FILL, 0,
                    0, 0
            );
        } else {
            container_add(parent, E.widget);
        }
    }
}
开发者ID:dmpas,项目名称:e1c83-form-gtk,代码行数:96,代码来源:main.c

示例10: _read_lustre_counters

/* _read_lustre_counters()
 * Read counters from all mounted lustre fs
 * from the file stats under the directories:
 *
 * /proc/fs/lustre/llite/lustre-xxxx
 *
 * From the file stat we use 2 entries:
 *
 * read_bytes          17996 samples [bytes] 0 4194304 30994606834
 * write_bytes         9007 samples [bytes] 2 4194304 31008331389
 *
 */
static int _read_lustre_counters(void)
{
	char lustre_dir[PATH_MAX];
	DIR *proc_dir;
	struct dirent *entry;
	FILE *fff;
	char buffer[BUFSIZ];


	snprintf(lustre_dir, PATH_MAX, "%s/llite", proc_base_path);

	proc_dir = opendir(lustre_dir);
	if (proc_dir == NULL) {
		error("%s: Cannot open %s %m", __func__, lustre_dir);
		return SLURM_ERROR;
	}

	while ((entry = readdir(proc_dir))) {
		char *path_stats = NULL;
		bool bread;
		bool bwrote;

		if (xstrcmp(entry->d_name, ".") == 0
		    || xstrcmp(entry->d_name, "..") == 0)
			continue;

		xstrfmtcat(path_stats, "%s/%s/stats",
			   lustre_dir, entry->d_name);
		debug3("%s: Found file %s", __func__, path_stats);

		fff = fopen(path_stats, "r");
		if (fff == NULL) {
			error("%s: Cannot open %s %m", __func__, path_stats);
			xfree(path_stats);
			continue;
		}
		xfree(path_stats);

		bread = bwrote = false;
		while (fgets(buffer, BUFSIZ, fff)) {

			if (bread && bwrote)
				break;

			if (strstr(buffer, "write_bytes")) {
				sscanf(buffer,
				       "%*s %"PRIu64" %*s %*s "
				       "%*d %*d %"PRIu64"",
				       &lustre_se.lustre_nb_writes,
				       &lustre_se.lustre_write_bytes);
				debug3("%s "
				       "%"PRIu64" "
				       "write_bytes %"PRIu64" "
				       "writes",
				       __func__,
				       lustre_se.lustre_write_bytes,
				       lustre_se.lustre_nb_writes);
				bwrote = true;
			}

			if (strstr(buffer, "read_bytes")) {
				sscanf(buffer,
				       "%*s %"PRIu64" %*s %*s "
				       "%*d %*d %"PRIu64"",
				       &lustre_se.lustre_nb_reads,
				       &lustre_se.lustre_read_bytes);
				debug3("%s "
				       "%"PRIu64" "
				       "read_bytes %"PRIu64" "
				       "reads",
				       __func__,
				       lustre_se.lustre_read_bytes,
				       lustre_se.lustre_nb_reads);
				bread = true;
			}
		}
		fclose(fff);

		lustre_se.all_lustre_write_bytes +=
			lustre_se.lustre_write_bytes;
		lustre_se.all_lustre_read_bytes += lustre_se.lustre_read_bytes;
		lustre_se.all_lustre_nb_writes += lustre_se.lustre_nb_writes;
		lustre_se.all_lustre_nb_reads += lustre_se.lustre_nb_reads;
		debug3("%s: all_lustre_write_bytes %"PRIu64" "
		       "all_lustre_read_bytes %"PRIu64"",
		       __func__, lustre_se.all_lustre_write_bytes,
		       lustre_se.all_lustre_read_bytes);
		debug3("%s: all_lustre_nb_writes %"PRIu64" "
//.........这里部分代码省略.........
开发者ID:chrisdukey,项目名称:slurm,代码行数:101,代码来源:acct_gather_filesystem_lustre.c

示例11: irc_parse_line


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

	if (colon2) {
		*colon2 = ' ';
		array_add(&args, xstrdup(colon2+2));
	}

#define prefix pfxcmd[0]
#define pfx_nick pfxcmd[1]
#define pfx_ihost pfxcmd[2]
#define cmdname pfxcmd[3]

	/* prefix is optional... */
	if (':' != *buf) {
		array_add(&pfxcmd, g_strdup(""));	// prefix
		array_add(&pfxcmd, g_strdup(""));	// pfx_nick
		array_add(&pfxcmd, g_strdup(""));	// pfx_ihost
	} else {
		array_add(&pfxcmd, array_shift(&args));						// prefix
		p = xstrchr(pfxcmd[0], '!');
		array_add(&pfxcmd, p ? g_strndup(pfxcmd[0], p-pfxcmd[0]) : g_strdup(""));	// pfx_nick
		array_add(&pfxcmd, p ? g_strdup(p+1) : g_strdup(""));				// pfx_ihost
	}

	cmd = array_shift(&args);
	array_add(&pfxcmd, cmd);		// cmdname

	/* debug only nasty hack ;> */
#ifdef GDEBUG
	/* mg: well, it's not the exact data sent, but color is needed indeed */
	i=0;
	if (*pfxcmd[0]) debug_iorecv("[%s]", pfxcmd[0]);
	debug_iorecv("[%s]", cmd);
	while (args[i] != NULL) debug_iorecv("[%s]",args[i++]);
	debug_iorecv("\n");
#endif

	n_params = g_strv_length(args);
	if (xstrlen(cmd) > 1) {
		if(!gatoi(cmd, &ecode)) {
			/* for scripts */
			char *emitname = saprintf("irc-protocol-numeric %s", cmd);
			if ((query_emit(NULL, "irc-protocol-numeric", &s->uid, &ecode, &args) == -1) ||
			    (query_emit(NULL, emitname, &s->uid, &args) == -1))
			{
				xfree(emitname);
				g_strfreev(pfxcmd);
				g_strfreev(args);
				return -1;
			}
			xfree(emitname);

			c=0;
			while(irccommands[c].type != -1) {
				if (irccommands[c].type == 1 && irccommands[c].num == ecode) {
					if (irccommands[c].min_params > n_params) {
						debug_error("[irc] parse_line() Not enough parameters! cmd=%s, n=%d, min=%d\n",
								cmd, n_params, irccommands[c].min_params);
					} else
					/* I'm sending c not ecode!!!! */
					if ((*(irccommands[c].handler))(s, j, c, pfxcmd, args) == -1 ) {
						debug_error("[irc] parse_line() error while executing handler!\n");
					}
					/* GiM: XXX I don't expect more,
					 * then one handler on list... */
					break;
				}
				c++;
			}
#ifdef GDEBUG
			if (irccommands[c].type == -1) {
				debug("trying default handler\n");
				if ((*(irccommands[0].handler))(s, j, 0, pfxcmd, args) == -1 ) {
					debug("[irc] parse_line() error while executing handler!\n");
				}

			}
#endif
		} else {
			c=0;
			while(irccommands[c].type != -1) {
				if (irccommands[c].type == 0 && !xstrcmp(irccommands[c].comm, cmd)) {
					if (irccommands[c].min_params > n_params) {
						debug_error("[irc] parse_line() Not enough parameters! cmd=%s, n=%d, min=%d\n",
								cmd, n_params, irccommands[c].min_params);
					} else
					/* dj: instead of  ecode,    c; */
					if ((*(irccommands[c].handler))(s, j, c, pfxcmd, args) == -1 ) {
						debug_error("[irc] parse_line() error while executing handler!\n");
					}
					break;
				}
				c++;
			}
		}
	}

	g_strfreev(pfxcmd);
	g_strfreev(args);
	return 0;
}
开发者ID:hiciu,项目名称:ekg2,代码行数:101,代码来源:misc.c

示例12: main

int main()
{
	LIST_STRU entries;
  	LIST_STRU configs;
  	char *configname = "simple-webmail.conf";
  	FILE *mail;
  	char *dest,*name,*from,*subject,*content;
	char command[256];

  	html_header();

  	read_cgi_input(&entries);
  	read_configs(&configs,configname);

  	if( (is_field_empty(entries,"name")) && (is_field_empty(entries,"from")) &&
      		(is_field_empty(entries,"subject")) && (is_field_empty(entries,"content")) )
	{
	    printf("重新输入!");
  	}
  	else
  	{

    		if (is_field_empty(entries,"to"))
      			dest = strdup(TO);
    		else
      			dest = strdup(cgi_val(entries,"to"));
		
		if (!xstrcmp("*@*.*",dest))
		{
			printf("收件人 %s 不是标准的邮件格式 *@*.*\n",dest);
			exit(-1);
		}
    		name = strdup(cgi_val(entries,"name"));
    		from = strdup(cgi_val(entries,"from"));
    		subject = strdup(cgi_val(entries,"subject"));
		
    		if (dest[0] == '\0')
      			strcpy(dest,WEBADMIN);

		sprintf(command,"%s %s",SENDMAIL,dest);

    		mail = popen(command,"w");
    		if (mail == NULL) 
    		{
      			html_begin("系统出错!");
      			printf("系统出错!");
      			printf("请发信给 %s 。 \r\n",WEBADMIN);
      			printf("<hr>\r\n简单WEB邮件发送程序 v 0.1 . 作者: ");
      			printf("<i>%s</i>.\r\n",WEBADMIN);
      			exit(-1);
      			html_end();
    		}
    		else 
    		{
      			content = strdup(cgi_val(entries,"content"));
      			fprintf(mail,"From: %s (%s)\n",from,name);
      			fprintf(mail,"Subject: %s\n",subject);
      			fprintf(mail,"To: %s\n",dest);
      			fprintf(mail,"X-Sender: %s\n\n",WEBADMIN);
	  		if (REMOTE_ADDR != NULL)
				fprintf(mail,"发送者 IP 地址 %s\n",REMOTE_ADDR);
			// 增加 http 代理 相关环境变量,可判断是否有代理服务器,可显示出非匿名代理的源地址  2003.08.17
  			if (HTTP_X_FORWARDED_FOR != NULL)
				fprintf(mail,"经过代理前IP地址 %s\n",HTTP_X_FORWARDED_FOR);
  			if (HTTP_CLIENT_IP != NULL)
				fprintf(mail,"代理服务器地址 %s\n",HTTP_CLIENT_IP);
      			fprintf(mail,"%s\n\n",content);
      			pclose(mail);
      			html_begin("邮件发送成功");
      			printf("邮件发送成功");
      			printf("你发送了以下的信息:\r\n<pre>\r\n");
      			printf("收信人: %s \r\n",dest);
      			printf("发信人: %s (%s)\r\n",from,name);
      			printf("标 题: %s\r\n\r\n",subject);
      			printf("%s\r\n</pre>\r\n",content);
	  		if (REMOTE_ADDR != NULL)
				printf("发送者 IP 地址 %s<br>\n",REMOTE_ADDR);
			// 增加 http 代理 相关环境变量,可判断是否有代理服务器,可显示出非匿名代理的源地址  2003.08.17
  			if (HTTP_X_FORWARDED_FOR != NULL)
				printf("经过代理前IP地址 %s<br>\n",HTTP_X_FORWARDED_FOR);
  			if (HTTP_CLIENT_IP != NULL)
				printf("代理服务器地址 %s<br>\n",HTTP_CLIENT_IP);
      			printf("谢谢使用!<p>\r\n");
      			printf("<hr>\r\n简单WEB邮件发送程序 v 0.1 . 作者: ");
      			printf("<i>%s</i>.\r\n",WEBADMIN);
      			html_end();
    		}
	}

  	list_clear(&entries);
  	list_clear(&configs);
  	return 0;
}
开发者ID:kansifang,项目名称:meteoric,代码行数:93,代码来源:simple-webmail.cgi.c

示例13: _xlate_before

static void _xlate_before(char *depend, uint32_t submit_uid, uint32_t my_job_id)
{
	uint32_t job_id;
	char *last_ptr = NULL, *new_dep = NULL, *tok, *type;
	struct job_record *job_ptr;
        pthread_attr_t attr;
	pthread_t dep_thread;


	tok = strtok_r(depend, ":", &last_ptr);
	if (!xstrcmp(tok, "before"))
		type = "after";
	else if (!xstrcmp(tok, "beforeany"))
		type = "afterany";
	else if (!xstrcmp(tok, "beforenotok"))
		type = "afternotok";
	else if (!xstrcmp(tok, "beforeok"))
		type = "afterok";
	else {
		info("%s: discarding invalid job dependency option %s",
		     plugin_type, tok);
		return;
	}

	/* NOTE: We are updating a job record here in order to implement
	 * the depend=before option. We are doing so without the write lock
	 * on the job record, but using a local mutex to prevent multiple
	 * updates on the same job when multiple jobs satisfying the dependency
	 * are being processed at the same time (all with read locks). The
	 * job read lock will prevent anyone else from getting a job write
	 * lock and using a job write lock causes serious performance problems
	 * for slow job_submit plugins. Not an ideal solution, but the best
	 * option that we see. */
	slurm_mutex_lock(&depend_mutex);
	tok = strtok_r(NULL, ":", &last_ptr);
	while (tok) {
		job_id = atoi(tok);
		job_ptr = find_job_record(job_id);
		if (!job_ptr) {
			info("%s: discarding invalid job dependency before %s",
			     plugin_type, tok);
		} else if ((submit_uid != job_ptr->user_id) &&
			   !validate_super_user(submit_uid)) {
			error("%s: Security violation: uid %u trying to alter "
			      "job %u belonging to uid %u", 
			      plugin_type, submit_uid, job_ptr->job_id,
			      job_ptr->user_id);
		} else if ((!IS_JOB_PENDING(job_ptr)) ||
			   (job_ptr->details == NULL)) {
			info("%s: discarding job before dependency on "
			     "non-pending job %u",
			     plugin_type, job_ptr->job_id);
		} else {
			if (job_ptr->details->dependency) {
				xstrcat(new_dep, job_ptr->details->dependency);
				xstrcat(new_dep, ",");
			}
			xstrfmtcat(new_dep, "%s:%u", type, my_job_id);
			xfree(job_ptr->details->dependency);
			job_ptr->details->dependency = new_dep;
			new_dep = NULL;
			_decr_depend_cnt(job_ptr);

			slurm_attr_init(&attr);
			pthread_attr_setdetachstate(&attr,
						    PTHREAD_CREATE_DETACHED);
			pthread_create(&dep_thread, &attr, _dep_agent, job_ptr);
			slurm_attr_destroy(&attr);
		}
		tok = strtok_r(NULL, ":", &last_ptr);
	}
	slurm_mutex_unlock(&depend_mutex);
}
开发者ID:artpol84,项目名称:slurm,代码行数:73,代码来源:job_submit_pbs.c

示例14: _create_block_list

static List _create_block_list(partition_info_msg_t *part_info_ptr,
			       block_info_msg_t *block_info_ptr)
{
	int i;
	static List block_list = NULL;
	static partition_info_msg_t *last_part_info_ptr = NULL;
	static block_info_msg_t *last_block_info_ptr = NULL;
	List last_list = NULL;
	ListIterator last_list_itr = NULL;
	sview_block_info_t *block_ptr = NULL;
	char tmp_mp_str[50];

	if (block_list && (part_info_ptr == last_part_info_ptr)
	    && (block_info_ptr == last_block_info_ptr))
		return block_list;

	last_part_info_ptr = part_info_ptr;
	if (block_list) {
		/* Only the partition info changed so lets update just
		   that part.
		*/
		if (block_info_ptr == last_block_info_ptr) {
			ListIterator itr = list_iterator_create(block_list);

			while ((block_ptr = list_next(itr)))
				_set_block_partition(part_info_ptr, block_ptr);

			return block_list;
		}
		last_list = block_list;
	}

	block_list = list_create(_block_list_del);
	if (!block_list) {
		g_print("malloc error\n");
		return NULL;
	}

	last_block_info_ptr = block_info_ptr;

	if (last_list)
		last_list_itr = list_iterator_create(last_list);
	for (i=0; i<block_info_ptr->record_count; i++) {
		/* If we don't have a block name just continue since
		   ths block hasn't been made in the system yet. */
		if (!block_info_ptr->block_array[i].bg_block_id)
			continue;

		block_ptr = NULL;

		if (last_list_itr) {
			while ((block_ptr = list_next(last_list_itr))) {
				if (!xstrcmp(block_ptr->bg_block_name,
					     block_info_ptr->
					     block_array[i].bg_block_id)) {
					list_remove(last_list_itr);
					_block_info_free(block_ptr);
					break;
				}
			}
			list_iterator_reset(last_list_itr);
		}

		if (!block_ptr)
			block_ptr = xmalloc(sizeof(sview_block_info_t));
		block_ptr->pos = i;
		block_ptr->bg_block_name
			= xstrdup(block_info_ptr->
				  block_array[i].bg_block_id);


		block_ptr->color_inx =
			atoi(block_ptr->bg_block_name+7);

		/* on some systems they make there own blocks named
		   whatever they want, so doing this fixes what could
		   be a negative number.
		*/
		if (block_ptr->color_inx < 0)
			block_ptr->color_inx = i;

		block_ptr->color_inx %= sview_colors_cnt;

		block_ptr->mp_str
			= xstrdup(block_info_ptr->block_array[i].mp_str);
		if (block_info_ptr->block_array[i].ionode_str) {
			block_ptr->small_block = 1;
			snprintf(tmp_mp_str, sizeof(tmp_mp_str),
				 "%s[%s]",
				 block_ptr->mp_str,
				 block_info_ptr->block_array[i].ionode_str);
			xfree(block_ptr->mp_str);
			block_ptr->mp_str = xstrdup(tmp_mp_str);
		}
		block_ptr->reason
			= xstrdup(block_info_ptr->block_array[i].reason);

		if (cluster_flags & CLUSTER_FLAG_BGP) {
			block_ptr->imagelinux = xstrdup(
				block_info_ptr->block_array[i].linuximage);
//.........这里部分代码省略.........
开发者ID:damienfrancois,项目名称:slurm,代码行数:101,代码来源:block_info.c

示例15: read_83_form

static form_element_t *
read_83_form(const char *path)
{

    xmlDoc *doc = NULL;
    xmlNode *root_element = NULL;
    const xmlNode *el;

    doc = xmlReadFile(path, NULL, 0);
    root_element = xmlDocGetRootElement(doc);

    el = find_by_name(root_element->children, "Elements");

    int grouping = GROUPING_VERTICAL;

    {
        const xmlNode *p = find_by_path(el, "Properties/ChildrenGrouping")->children;

        if (xstrcmp(p->content, "Vertical") != 0)
            grouping = GROUPING_HORIZONTAL;
    }

    el = find_by_path(el, "ContainedItems");

    form_element_t *form = malloc(sizeof(*form));

    form->widget = grouping == GROUPING_HORIZONTAL
            ? gtk_hbox_new(false, 2)
            : gtk_vbox_new(false, 2)
    ;
    form->box = true;

    {
        const xmlNode *pre = find_by_name(root_element->children, "Elements");
        pre = find_by_path(pre, "PredefinedContainedItems");

        if (pre->children) {

            form_element_t vbox, pre_box;
            vbox.widget = gtk_vbox_new(false, 0);
            vbox.box = true;

            pre_box.widget = gtk_vbox_new(false, 0);
            pre_box.box = true;

            load_form_elements(pre->children, &pre_box);

            gtk_box_pack_start(GTK_BOX(vbox.widget), pre_box.widget, false, false, 0);
            gtk_box_pack_start(GTK_BOX(vbox.widget), form->widget, false, false, 0);

            form->widget = vbox.widget;
        }
    }

    load_form_elements(el->children, form);

    xmlFreeDoc(doc);

    xmlCleanupParser();

    return form;
}
开发者ID:dmpas,项目名称:e1c83-form-gtk,代码行数:62,代码来源:main.c


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