本文整理汇总了C++中ARRAY_ITEM函数的典型用法代码示例。如果您正苦于以下问题:C++ ARRAY_ITEM函数的具体用法?C++ ARRAY_ITEM怎么用?C++ ARRAY_ITEM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ARRAY_ITEM函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: server_lock
void
server_lock(void)
{
struct client *c;
static struct passwd *pw, pwstore;
static char pwbuf[_PW_BUF_LEN];
u_int i;
if (server_locked)
return;
if (getpwuid_r(getuid(), &pwstore, pwbuf, sizeof pwbuf, &pw) != 0) {
server_locked_pw = NULL;
return;
}
server_locked_pw = pw;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session == NULL)
continue;
status_prompt_clear(c);
status_prompt_set(c,
"Password:", server_lock_callback, NULL, c, PROMPT_HIDDEN);
server_redraw_client(c);
}
server_locked = 1;
}
开发者ID:ThomasAdam,项目名称:tmux-ARCHIVED,代码行数:30,代码来源:server-fn.c
示例2: tty_write
void
tty_write(void (*cmdfn)(
struct tty *, const struct tty_ctx *), const struct tty_ctx *ctx)
{
struct window_pane *wp = ctx->wp;
struct client *c;
u_int i;
/* wp can be NULL if updating the screen but not the terminal. */
if (wp == NULL)
return;
if (wp->window->flags & WINDOW_REDRAW || wp->flags & PANE_REDRAW)
return;
if (wp->window->flags & WINDOW_HIDDEN || !window_pane_visible(wp))
return;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session == NULL)
continue;
if (c->flags & CLIENT_SUSPENDED)
continue;
if (c->session->curw->window == wp->window) {
if (c->tty.flags & TTY_FREEZE || c->tty.term == NULL)
continue;
cmdfn(&c->tty, ctx);
}
}
}
开发者ID:jnbek,项目名称:tmux,代码行数:31,代码来源:tty.c
示例3: cmd_list_sessions_exec
int
cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx)
{
struct session *s;
struct session_group *sg;
char *tim, tmp[64];
u_int i, idx;
time_t t;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i);
if (s == NULL)
continue;
sg = session_group_find(s);
if (sg == NULL)
*tmp = '\0';
else {
idx = session_group_index(sg);
xsnprintf(tmp, sizeof tmp, " (group %u)", idx);
}
t = s->creation_time.tv_sec;
tim = ctime(&t);
*strchr(tim, '\n') = '\0';
ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]%s%s",
s->name, winlink_count(&s->windows), tim, s->sx, s->sy,
tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)");
}
return (0);
}
开发者ID:ThomasAdam,项目名称:tmux-ARCHIVED,代码行数:33,代码来源:cmd-list-sessions.c
示例4: ci_alist_hash
/*
* Returns an entry that has been displaced, if any.
*/
array_item *add_to_array (array *a, array_item *item)
{
int count;
int location = 0;
array_item * ret = NULL;
u_32int_t mask; /* Dummy var */
if (a->hash == HASH_INSENSITIVE)
item->hash = ci_alist_hash(item->name, &mask);
else
item->hash = cs_alist_hash(item->name, &mask);
check_array_size(a);
if (a->max)
{
find_array_item(a, item->name, &count, &location);
if (count < 0)
{
ret = ARRAY_ITEM(a, location);
a->max--;
}
else
move_array_items(a, location, a->max, 1);
}
a->list[location] = item;
a->max++;
return ret;
}
开发者ID:srfrog,项目名称:epic5,代码行数:32,代码来源:alist.c
示例5: control_notify_window_layout_changed
void
control_notify_window_layout_changed(struct window *w)
{
struct client *c;
struct session *s;
struct format_tree *ft;
struct winlink *wl;
u_int i;
const char *template;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
continue;
s = c->session;
if (winlink_find_by_window_id(&s->windows, w->id) == NULL)
continue;
#ifndef TMATE_SLAVE
/*
* When the last pane in a window is closed it won't have a
* layout root and we don't need to inform the client about the
* layout change because the whole window will go away soon.
*/
if (w->layout_root == NULL)
continue;
开发者ID:goller,项目名称:tmate-slave,代码行数:27,代码来源:control-notify.c
示例6: cmd_list_clients_exec
/* ARGSUSED */
int
cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct args *args = self->args;
struct client *c;
struct session *s;
u_int i;
const char *s_utf8;
if (args_has(args, 't')) {
s = cmd_find_session(ctx, args_get(args, 't'), 0);
if (s == NULL)
return (-1);
} else
s = NULL;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session == NULL)
continue;
if (c->tty.flags & TTY_UTF8)
s_utf8 = " (utf8)";
else
s_utf8 = "";
if (s != NULL && s != c->session)
continue;
ctx->print(ctx, "%s: %s [%ux%u %s]%s", c->tty.path,
c->session->name, c->tty.sx, c->tty.sy,
c->tty.termname, s_utf8);
}
return (0);
}
开发者ID:ThomasAdam,项目名称:tmux-cvs-archived,代码行数:36,代码来源:cmd-list-clients.c
示例7: server_unlock
int
server_unlock(const char *s)
{
struct client *c;
u_int i;
char *out;
if (!server_locked)
return (0);
if (server_password != NULL) {
if (s == NULL)
return (-1);
out = crypt(s, server_password);
if (strcmp(out, server_password) != 0)
return (-1);
}
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c == NULL)
continue;
status_prompt_clear(c);
server_redraw_client(c);
}
server_locked = 0;
return (0);
}
开发者ID:jnbek,项目名称:tmux,代码行数:30,代码来源:server-fn.c
示例8: paste_get_index
/* Get an item by its index. */
struct paste_buffer *
paste_get_index(struct paste_stack *ps, u_int idx)
{
if (idx >= ARRAY_LENGTH(ps))
return (NULL);
return (ARRAY_ITEM(ps, idx));
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:8,代码来源:paste.c
示例9: fetch_mbox_make
/* Make an array of all the mboxes to visit. */
int
fetch_mbox_make(struct account *a)
{
struct fetch_mbox_data *data = a->data;
struct fetch_mbox_mbox *fmbox;
char *path;
u_int i, j;
glob_t g;
ARRAY_INIT(&data->fmboxes);
for (i = 0; i < ARRAY_LENGTH(data->mboxes); i++) {
path = ARRAY_ITEM(data->mboxes, i);
if (glob(path, GLOB_BRACE|GLOB_NOCHECK, NULL, &g) != 0) {
log_warn("%s: glob(\"%s\")", a->name, path);
goto error;
}
if (g.gl_pathc < 1)
fatalx("glob returned garbage");
for (j = 0; j < (u_int) g.gl_pathc; j++) {
fmbox = xcalloc(1, sizeof *fmbox);
fmbox->path = xstrdup(g.gl_pathv[j]);
fmbox->fd = -1;
fmbox->base = NULL;
ARRAY_ADD(&data->fmboxes, fmbox);
}
globfree(&g);
}
return (0);
error:
for (i = 0; i < ARRAY_LENGTH(&data->fmboxes); i++) {
fmbox = ARRAY_ITEM(&data->fmboxes, i);
xfree(fmbox->path);
xfree(fmbox);
}
ARRAY_FREE(&data->fmboxes);
return (-1);
}
开发者ID:mbeck-,项目名称:fdm,代码行数:45,代码来源:fetch-mbox.c
示例10: move_array_items
/*
* Move ``start'' through ``end'' array elements ``dir'' places up
* in the array. If ``dir'' is negative, move them down in the array.
* Fill in the vacated spots with NULLs.
*/
void move_array_items (array *a, int start, int end, int dir)
{
int i;
if (dir > 0)
{
for (i = end; i >= start; i--)
LARRAY_ITEM(a, i + dir) = ARRAY_ITEM(a, i);
for (i = dir; i > 0; i--)
LARRAY_ITEM(a, start + i - 1) = NULL;
}
else if (dir < 0)
{
for (i = start; i <= end; i++)
LARRAY_ITEM(a, i + dir) = ARRAY_ITEM(a, i);
for (i = end - dir + 1; i <= end; i++)
LARRAY_ITEM(a, i) = NULL;
}
}
开发者ID:carriercomm,项目名称:epic4,代码行数:24,代码来源:alist.c
示例11: keywords_clear
void
keywords_clear()
{
int i;
for (i = 0; i < ARRAY_LENGTH(&keywords); i++)
xfree(ARRAY_ITEM(&keywords, i));
ARRAY_CLEAR(&keywords);
}
开发者ID:wujiang,项目名称:mdp,代码行数:10,代码来源:keywords.c
示例12: imap_state_select1
/* Select state 1. */
int
imap_state_select1(struct account *a, struct fetch_ctx *fctx)
{
struct fetch_imap_data *data = a->data;
if (imap_putln(a, "%u SELECT {%zu}",
++data->tag, strlen(ARRAY_ITEM(data->folders, data->folder))) != 0)
return (FETCH_ERROR);
fctx->state = imap_state_select2;
return (FETCH_BLOCK);
}
开发者ID:upwhere,项目名称:fdm,代码行数:12,代码来源:imap-common.c
示例13: num_clients
static int num_clients(void)
{
unsigned int i, count = 0;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
if (ARRAY_ITEM(&clients, i))
count++;
}
return count;
}
开发者ID:masteinhauser,项目名称:tmate-slave,代码行数:11,代码来源:tmate-encoder.c
示例14: print_results
void
print_results()
{
int i;
struct result *result;
for (i = 0; i < ARRAY_LENGTH(&results); i++) {
result = ARRAY_ITEM(&results, i);
if (result->status == RESULT_SHOW)
printf("%ls\n", result->value);
}
}
开发者ID:pbleser,项目名称:mdp,代码行数:12,代码来源:main.c
示例15: imap_state_body
/* Body state. */
int
imap_state_body(struct account *a, struct fetch_ctx *fctx)
{
struct fetch_imap_data *data = a->data;
struct mail *m = fctx->mail;
struct fetch_imap_mail *aux;
char *line, *ptr;
u_int n;
if (imap_getln(a, fctx, IMAP_UNTAGGED, &line) != 0)
return (FETCH_ERROR);
if (line == NULL)
return (FETCH_BLOCK);
if (sscanf(line, "* %u FETCH (", &n) != 1)
return (imap_invalid(a, line));
if ((ptr = strstr(line, "BODY[] {")) == NULL)
return (imap_invalid(a, line));
if (sscanf(ptr, "BODY[] {%zu}", &data->size) != 1)
return (imap_invalid(a, line));
data->lines = 0;
/* Fill in local data. */
aux = xcalloc(1, sizeof *aux);
aux->uid = ARRAY_FIRST(&data->wanted);
m->auxdata = aux;
m->auxfree = imap_free;
ARRAY_REMOVE(&data->wanted, 0);
/* Open the mail. */
if (mail_open(m, data->size) != 0) {
log_warnx("%s: failed to create mail", a->name);
return (FETCH_ERROR);
}
m->size = 0;
/* Tag mail. */
default_tags(&m->tags, data->src);
if (data->server.host != NULL) {
add_tag(&m->tags, "server", "%s", data->server.host);
add_tag(&m->tags, "port", "%s", data->server.port);
}
add_tag(&m->tags, "server_uid", "%u", aux->uid);
add_tag(&m->tags,
"folder", "%s", ARRAY_ITEM(data->folders, data->folder));
/* If we already know the mail is oversize, start off flushing it. */
data->flushing = data->size > conf.max_size;
fctx->state = imap_state_line;
return (FETCH_AGAIN);
}
开发者ID:upwhere,项目名称:fdm,代码行数:54,代码来源:imap-common.c
示例16: ARRAY_ITEM
/* Remove the 'which'th item from the given array */
Array_item *BX_array_pop (Array *array, int which)
{
Array_item *ret = NULL;
if (which < 0 || which >= array->max)
return NULL;
ret = ARRAY_ITEM(array, which);
move_array_items(array, which + 1, array->max, -1);
array->max--;
return ret;
}
开发者ID:Cloudxtreme,项目名称:bitchx,代码行数:13,代码来源:alist.c
示例17: set_wrapped
void
set_wrapped(struct mail *m, char ch)
{
u_int i;
if (m->wrapchar == ch)
return;
m->wrapchar = ch;
for (i = 0; i < ARRAY_LENGTH(&m->wrapped); i++)
m->data[ARRAY_ITEM(&m->wrapped, i)] = ch;
}
开发者ID:avkrotov,项目名称:fdm,代码行数:12,代码来源:mail.c
示例18: ARRAY_ITEM
/* Remove the 'which'th item from the given array */
array_item *array_pop (array *a, int which)
{
array_item *ret = NULL;
if (which < 0 || which >= a->max)
return NULL;
ret = ARRAY_ITEM(a, which);
move_array_items(a, which + 1, a->max, -1);
a->max--;
check_array_size(a);
return ret;
}
开发者ID:carriercomm,项目名称:epic4,代码行数:14,代码来源:alist.c
示例19: cfg_print_causes
void
cfg_print_causes(struct cmd_q *cmdq)
{
char *cause;
u_int i;
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
cause = ARRAY_ITEM(&cfg_causes, i);
cmdq_print(cmdq, "%s", cause);
free(cause);
}
ARRAY_FREE(&cfg_causes);
}
开发者ID:JonAWhite,项目名称:tmux,代码行数:13,代码来源:cfg.c
示例20: window_more_free
void
window_more_free(struct window_pane *wp)
{
struct window_more_mode_data *data = wp->modedata;
u_int i;
for (i = 0; i < ARRAY_LENGTH(&data->list); i++)
xfree(ARRAY_ITEM(&data->list, i));
ARRAY_FREE(&data->list);
screen_free(&data->screen);
xfree(data);
}
开发者ID:ThomasAdam,项目名称:tmux-ARCHIVED,代码行数:13,代码来源:window-more.c
注:本文中的ARRAY_ITEM函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论