int main() { int i, j, s, sum=0; UNDIRECTED first=NULL, min; printf("Enter number of vertices\n"); scanf("%d", &n); for(i=0;i<n;i++) { for(j=0;j<n;j++) { scanf("%d", &input[i][j]); } } printf("Enter source\n"); scanf("%d", &s); reset_all(); remove_element_array(vertex, &vindex, s); push_array(finished, &findex, s); while(findex<n-1) { for(i=0;i<=findex;i++) { for(j=0;j<=vindex;j++) { first=insert_ll(first, new_connection(finished[i], vertex[j])); } } min=find_minimum(first); push_array(finished, &findex, min->d); remove_element_array(vertex, &vindex, min->d); first=destroy_ll(first); sum+=distance(min->s, min->d); printf("%d->%d = %d\n", min->s, min->d, distance(min->s, min->d)); } printf("Total distance = %d\n", sum); return 0; }
int pr_parser_prepare(pool *p, xaset_t **parsed_servers) { if (p == NULL) { if (parser_pool == NULL) { parser_pool = make_sub_pool(permanent_pool); pr_pool_tag(parser_pool, "Parser Pool"); } p = parser_pool; } if (parsed_servers == NULL) { parser_server_list = &server_list; } else { parser_server_list = parsed_servers; } parser_servstack = make_array(p, 1, sizeof(server_rec *)); parser_curr_server = (server_rec **) push_array(parser_servstack); *parser_curr_server = main_server; parser_confstack = make_array(p, 10, sizeof(config_rec *)); parser_curr_config = (config_rec **) push_array(parser_confstack); *parser_curr_config = NULL; return 0; }
/* Many FTP servers (e.g. IIS) use the semicolon delimiter syntax, as used * for listing the MLSD/MLST facts, for other FEAT values (e.g. AUTH, PROT, * etc). * * NOTE: Should this return a table rather than an array, for easier lookup * of parsed values by callers? */ static int parse_feat(pool *p, const char *feat, array_header **res) { char *ptr, *ptr2 = NULL; array_header *vals; size_t len; vals = make_array(p, 1, sizeof(char *)); /* No semicolons in this value? No work to do...*/ ptr = strchr(feat, ';'); if (ptr == NULL) { *((char **) push_array(vals)) = pstrdup(p, feat); *res = vals; return vals->nelts; } len = ptr - feat; if (len > 0) { *((char **) push_array(vals)) = pstrndup(p, feat, len); } /* Watch for any sequences of just semicolons. */ while (*ptr == ';') { pr_signals_handle(); ptr++; } ptr2 = strchr(ptr, ';'); while (ptr2 != NULL) { pr_signals_handle(); len = ptr2 - ptr; if (len > 0) { *((char **) push_array(vals)) = pstrndup(p, ptr, len); } ptr = ptr2; while (*ptr == ';') { pr_signals_handle(); ptr++; } ptr2 = strchr(ptr, ';'); } /* Since the semicolon delimiter syntax uses a trailing semicolon, * we shouldn't need to worry about something like "...;FOO". Right? */ *res = vals; return vals->nelts; }
static void tokenize( struct pike_string *s ) { int in_string = 0; unsigned int ts=0, i, len=s->len; const char *data = s->str; struct svalue *osp = Pike_sp; push_array( allocate_array_no_init( 0, 100 ) ); for( i=0; i<len; i++ ) { if( in_string ) { if( (data[i]=='@') ) { if( data[i+1]!='@' ) { push_token( data, ts, i-1 ); in_string=0; ts=i+1; } else i++; } } else { switch( data[i] ) { case '@': ts=i+1; in_string=1; break; case ':': case ' ': case '\t': case '\n': case '\r': if( ts < i ) push_token( data, ts, i-1 ); ts=i+1; break; case ';': if( ts < i ) push_token( data, ts, i-1 ); ts=i+1; push_array( allocate_array_no_init( 0, 10 ) ); break; } } } if( ts < len ) push_token( data, ts, len-1 ); f_aggregate( Pike_sp-osp ); }
int pr_ctrls_parse_msg(pool *msg_pool, char *msg, unsigned int *msgargc, char ***msgargv) { char *tmp = msg, *str = NULL; pool *tmp_pool = NULL; array_header *msgs = NULL; /* Sanity checks */ if (!msg_pool || !msgargc || !msgargv) { errno = EINVAL; return -1; } tmp_pool = make_sub_pool(msg_pool); /* Allocate an array_header, and push each space-delimited string * (respecting quotes and escapes) into the array. Once done, * destroy the array. */ msgs = make_array(tmp_pool, 0, sizeof(char *)); while ((str = ctrls_sep(&tmp)) != NULL) *((char **) push_array(msgs)) = pstrdup(msg_pool, str); *msgargc = msgs->nelts; *msgargv = (char **) msgs->elts; destroy_pool(tmp_pool); return 0; }
static array_header *path_split(pool *p, const char *path) { char buf[PR_TUNABLE_PATH_MAX+1], *full_path; size_t full_pathlen; array_header *first, *components; pr_fs_virtual_path(path, buf, sizeof(buf)-1); full_path = buf; full_pathlen = strlen(full_path); /* If the path ENDS in '/', append '.' to it. */ if (full_path[full_pathlen-1] == '/' && full_pathlen < (sizeof(buf)-1)) { full_path[full_pathlen] = '.'; } first = make_array(p, 1, sizeof(char *)); /* The first component is ALWAYS '/'. */ *((char **) push_array(first)) = pstrdup(p, "/"); if (full_pathlen == 1) { return first; } components = pr_str_text_to_array(p, full_path, '/'); if (components != NULL) { components = append_arrays(p, first, components); } pr_trace_msg(trace_channel, 19, "split path '%s' into %u components", path, components->nelts); return components; }
pr_regex_t *pr_regexp_alloc(module *m) { pr_regex_t *pre = NULL; pool *re_pool = NULL; /* If no regex-tracking list has been allocated, create one. Register a * cleanup handler for this pool, to free up the data in the list. */ if (regexp_pool == NULL) { regexp_pool = make_sub_pool(permanent_pool); pr_pool_tag(regexp_pool, "Regexp Pool"); regexp_list = make_array(regexp_pool, 0, sizeof(pr_regex_t *)); } re_pool = pr_pool_create_sz(regexp_pool, 128); pr_pool_tag(re_pool, "regexp pool"); pre = pcalloc(re_pool, sizeof(pr_regex_t)); pre->regex_pool = re_pool; pre->m = m; /* Add this pointer to the array. */ *((pr_regex_t **) push_array(regexp_list)) = pre; return pre; }
/*! @decl array(string) split(string s) *! Works as @[match], but returns an array of the strings that *! matched the subregexps. Subregexps are those contained in "( )" in *! the regexp. Subregexps that were not matched will contain zero. *! If the total regexp didn't match, zero is returned. *! *! @bugs *! You can currently only have 39 subregexps. *! *! @bugs *! The current implementation doesn't support searching *! in strings containing the NUL character or any *! wide character. *! *! @seealso *! @[match] */ static void regexp_split(INT32 args) { struct pike_string *s; struct regexp *r; get_all_args("Regexp.SimpleRegexp->split", args, "%S", &s); if(pike_regexec(r=THIS->regexp, s->str)) { int i,j; add_ref(s); pop_n_elems(args); for(j=i=1;i<NSUBEXP;i++) { if(!r->startp[i] || !r->endp[i]) { push_int(0); }else{ push_string(make_shared_binary_string(r->startp[i], r->endp[i]-r->startp[i])); j=i; } } if(j<i-1) pop_n_elems(i-j-1); push_array(aggregate_array(j)); free_string(s); }else{ pop_n_elems(args); push_int(0); } }
/* **| method: array(string) explode_dn ( string dn ); **| alt: array(string) explode_dn ( string dn, int notypes ); **| Takes a DN and converts it into an array of its components, **| called RDN (Relative Distinguished Name). ** **| arg: string dn **| The DN to explode. ** **| arg: int notypes **| If != 0 then the types of the DN components will be ignored and **| *not present in the output. Defaults to 1. ** **| returns: an array of RDN entries. */ static void f_ldap_explode_dn(INT32 args) { struct pike_string *dn; char **edn; int notypes = 1; switch (args) { case 2: if (ARG(2).type != T_INT) Pike_error("OpenLDAP.Client->explode_dn(): argument 2 must be an integer\n"); notypes = ARG(2).u.integer; /* fall through */ case 1: if (ARG(1).type != T_STRING) Pike_error("OpenLDAP.Client->explode_dn(): argument 1 must be an integer\n"); dn = ARG(1).u.string; break; default: Pike_error("OpenLDAP.Client->explode_dn(): expects at most 2 and at least 1 argument\n"); break; } pop_n_elems(args); edn = ldap_explode_dn(dn->str, notypes); if (!edn) { push_int(0); return; } push_array(make_pike_array(edn)); ldap_value_free(edn); }
int pr_ctrls_add_response(pr_ctrls_t *ctrl, char *fmt, ...) { char buf[PR_TUNABLE_BUFFER_SIZE] = {'\0'}; va_list resp; /* Sanity check */ if (!ctrl || !fmt) { errno = EINVAL; return -1; } /* Make sure the pr_ctrls_t has a temporary pool, from which the responses * will be allocated */ if (!ctrl->ctrls_tmp_pool) { ctrl->ctrls_tmp_pool = make_sub_pool(ctrls_pool); pr_pool_tag(ctrl->ctrls_tmp_pool, "ctrls tmp pool"); } if (!ctrl->ctrls_cb_resps) ctrl->ctrls_cb_resps = make_array(ctrl->ctrls_tmp_pool, 0, sizeof(char *)); /* Affix the message */ va_start(resp, fmt); vsnprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), fmt, resp); va_end(resp); buf[sizeof(buf) - 1] = '\0'; /* add the given response */ *((char **) push_array(ctrl->ctrls_cb_resps)) = pstrdup(ctrl->ctrls_tmp_pool, buf); return 0; }
/* Return an array of all supported/known configuration directives. */ static array_header *get_all_directives(pool *p) { array_header *names; conftable *tab; int idx; unsigned int hash; names = make_array(p, 1, sizeof(const char *)); idx = -1; hash = 0; tab = pr_stash_get_symbol2(PR_SYM_CONF, NULL, NULL, &idx, &hash); while (idx != -1) { pr_signals_handle(); if (tab != NULL) { *((const char **) push_array(names)) = pstrdup(p, tab->directive); } else { idx++; } tab = pr_stash_get_symbol2(PR_SYM_CONF, NULL, tab, &idx, &hash); } return names; }
MODRET add_lmd_allow_from(cmd_rec *cmd) { config_rec *c; int i; array_header *allowed_acls; if(cmd->argc < 2 ) CONF_ERROR(cmd, "argument missing"); CHECK_CONF(cmd, CONF_ROOT|CONF_GLOBAL); /* argv => LMDMemcachedHost 127.0.0.1 192.168.0.1 ... */ c = find_config(main_server->conf, CONF_PARAM, "LMDBAllow", FALSE); if(c && c->argv[0]) { allowed_acls = c->argv[0]; } else { c = add_config_param(cmd->argv[0], 0, NULL); c->argv[0] = allowed_acls = make_array(cmd->server->pool, 0, sizeof(char *)); } for(i=1; i < cmd->argc; i++) { char *entry = cmd->argv[i]; if (strcasecmp(entry, "all") == 0 || strcasecmp(entry, "none") == 0) { break; } pr_netacl_t *acl = pr_netacl_create(cmd->server->pool, entry); *((pr_netacl_t **) push_array(allowed_acls)) = acl; pr_log_debug(DEBUG2, "%s: add LMDBAllow[%d] %s", MODULE_NAME, i, entry); } return PR_HANDLED(cmd); }
int pr_ctrls_add_arg(pr_ctrls_t *ctrl, char *ctrls_arg) { /* Sanity checks */ if (!ctrl || !ctrls_arg) { errno = EINVAL; return -1; } /* Make sure the pr_ctrls_t has a temporary pool, from which the args will * be allocated. */ if (!ctrl->ctrls_tmp_pool) { ctrl->ctrls_tmp_pool = make_sub_pool(ctrls_pool); pr_pool_tag(ctrl->ctrls_tmp_pool, "ctrls tmp pool"); } if (!ctrl->ctrls_cb_args) ctrl->ctrls_cb_args = make_array(ctrl->ctrls_tmp_pool, 0, sizeof(char *)); /* Add the given argument */ *((char **) push_array(ctrl->ctrls_cb_args)) = pstrdup(ctrl->ctrls_tmp_pool, ctrls_arg); return 0; }
void reset_all() { int i; vindex=-1; for(i=0;i<n;i++) { push_array(vertex, &vindex, i); } findex=-1; }
static array_header *sqltab_fetch_daemons_cb(wrap2_table_t *sqltab, const char *name) { array_header *daemons_list = make_array(sqltab->tab_pool, 1, sizeof(char *)); /* Simply return the service name we're given. */ *((char **) push_array(daemons_list)) = pstrdup(sqltab->tab_pool, name); return daemons_list; }
static void add_config_ctxt(config_rec *c) { if (!*parser_curr_config) { *parser_curr_config = c; } else { parser_curr_config = (config_rec **) push_array(parser_confstack); *parser_curr_config = c; } }
END_TEST START_TEST (expr_eval_group_and_test) { char *names1[3] = { "foo", "bar", NULL }, *names2[2] = { "test", NULL }, *names3[2] = { "!baz", NULL }; int res; res = pr_expr_eval_group_and(NULL); fail_unless(res == -1, "Failed to handle null argument"); fail_unless(errno == EINVAL, "Failed to set errno to EINVAL"); session.group = NULL; session.groups = NULL; res = pr_expr_eval_group_and(names1); fail_unless(res == FALSE, "Expected FALSE, got TRUE"); session.group = "test"; res = pr_expr_eval_group_and(names1); fail_unless(res == FALSE, "Expected FALSE, got TRUE"); res = pr_expr_eval_group_and(names2); fail_unless(res == TRUE, "Expected TRUE, got FALSE"); res = pr_expr_eval_group_and(names3); fail_unless(res == TRUE, "Expected TRUE, got FALSE"); session.group = NULL; session.groups = make_array(p, 2, sizeof(char *)); *((char **) push_array(session.groups)) = "test"; *((char **) push_array(session.groups)) = NULL; *((char **) push_array(session.groups)) = "spank"; res = pr_expr_eval_group_and(names1); fail_unless(res == FALSE, "Expected FALSE, got TRUE"); res = pr_expr_eval_group_and(names2); fail_unless(res == TRUE, "Expected TRUE, got FALSE"); res = pr_expr_eval_group_and(names3); fail_unless(res == TRUE, "Expected TRUE, got FALSE"); }
static void exec_parse_cmds(config_rec *c, char *cmds) { char *cmd = NULL; array_header *cmd_array = NULL; /* Allocate an array_header. */ cmd_array = make_array(c->pool, 0, sizeof(char *)); /* Add each command to the array. */ while ((cmd = exec_get_cmd(&cmds)) != NULL) *((char **) push_array(cmd_array)) = pstrdup(c->pool, cmd); /* Terminate the array with a NULL. */ *((char **) push_array(cmd_array)) = NULL; /* Store the array of commands in the config_rec. */ c->argv[1] = cmd_array; return; }
static Range_Array get_enclosure_ranges(Application_Links *app, Partition *part, Buffer_Summary *buffer, int32_t pos, uint32_t flags){ Range_Array array = {0}; array.ranges = push_array(part, Range, 0); for (;;){ Range range = {0}; if (find_scope_range(app, buffer, pos, &range, flags)){ Range *r = push_array(part, Range, 1); *r = range; pos = range.first; } else{ break; } } array.count = (int32_t)(push_array(part, Range, 0) - array.ranges); return(array); }
void pr_ctrls_set_user_acl(pool *usr_acl_pool, ctrls_usr_acl_t *usr_acl, const char *allow, char *userlist) { char *user = NULL, **users = NULL; array_header *uid_list = NULL; uid_t uid = 0; pool *tmp_pool = NULL; /* Sanity checks */ if (usr_acl_pool == NULL || usr_acl == NULL || allow == NULL || userlist == NULL) { return; } tmp_pool = make_sub_pool(usr_acl_pool); if (strncmp(allow, "allow", 6) == 0) { usr_acl->allow = TRUE; } else { usr_acl->allow = FALSE; } /* Parse the given expression into an array, then retrieve the UID * for each given name. */ users = pr_ctrls_parse_acl(usr_acl_pool, userlist); /* Allocate an array of uid_t's */ uid_list = make_array(usr_acl_pool, 0, sizeof(uid_t)); for (user = *users; user != NULL; user = *++users) { /* Handle a user name of "*" differently. */ if (strncmp(user, "*", 2) == 0) { usr_acl->nuids = 1; usr_acl->uids = NULL; destroy_pool(tmp_pool); return; } else { uid = pr_auth_name2uid(tmp_pool, user); if (uid == (uid_t) -1) continue; } *((uid_t *) push_array(uid_list)) = uid; } usr_acl->nuids = uid_list->nelts; usr_acl->uids = (uid_t *) uid_list->elts; destroy_pool(tmp_pool); }
void pr_ctrls_set_group_acl(pool *grp_acl_pool, ctrls_grp_acl_t *grp_acl, const char *allow, char *grouplist) { char *group = NULL, **groups = NULL; array_header *gid_list = NULL; gid_t gid = 0; pool *tmp_pool = NULL; if (grp_acl_pool == NULL || grp_acl == NULL || allow == NULL || grouplist == NULL) { return; } tmp_pool = make_sub_pool(grp_acl_pool); if (strncmp(allow, "allow", 6) == 0) { grp_acl->allow = TRUE; } else { grp_acl->allow = FALSE; } /* Parse the given expression into an array, then retrieve the GID * for each given name. */ groups = pr_ctrls_parse_acl(grp_acl_pool, grouplist); /* Allocate an array of gid_t's */ gid_list = make_array(grp_acl_pool, 0, sizeof(gid_t)); for (group = *groups; group != NULL; group = *++groups) { /* Handle a group name of "*" differently. */ if (strncmp(group, "*", 2) == 0) { grp_acl->ngids = 1; grp_acl->gids = NULL; destroy_pool(tmp_pool); return; } else { gid = pr_auth_name2gid(tmp_pool, group); if (gid == (gid_t) -1) continue; } *((gid_t *) push_array(gid_list)) = gid; } grp_acl->ngids = gid_list->nelts; grp_acl->gids = (gid_t *) gid_list->elts; destroy_pool(tmp_pool); }
/*! @decl array(array(string)|string) tokenize(string code) *! *! Tokenize a string of Pike tokens. *! *! @returns *! Returns an array with Pike-level tokens and the remainder (a *! partial token), if any. */ static void f_tokenize( INT32 args ) { struct array *res; struct pike_string *left_s = NULL; /* Make gcc happy. */ struct pike_string *data; int left; ONERROR tmp; get_all_args("tokenize", args, "%W", &data); if(!data->len) { pop_n_elems(args); push_empty_array(); push_empty_string(); f_aggregate(2); return; } res = allocate_array_no_init( 0, 128 ); SET_ONERROR(tmp, do_free_arrayptr, &res); switch(data->size_shift) { case 0: left = tokenize0(&res, STR0(data), data->len); left_s = make_shared_binary_string0(STR0(data)+left, data->len-left); break; case 1: left = tokenize1(&res, STR1(data), data->len); left_s = make_shared_binary_string1(STR1(data)+left, data->len-left); break; case 2: left = tokenize2(&res,STR2(data), data->len); left_s = make_shared_binary_string2(STR2(data)+left, data->len-left); break; #ifdef PIKE_DEBUG default: Pike_error("Unknown shift size %d.\n", data->size_shift); #endif } UNSET_ONERROR(tmp); pop_n_elems(args); if (!res->size) { free_array(res); push_empty_array(); } else push_array(res); push_string( left_s ); f_aggregate( 2 ); }
static void mark_enclosures(Application_Links *app, Partition *scratch, Managed_Scope render_scope, Buffer_Summary *buffer, int32_t pos, uint32_t flags, Marker_Visual_Type type, int_color *back_colors, int_color *fore_colors, int32_t color_count){ Temp_Memory temp = begin_temp_memory(scratch); Range_Array ranges = get_enclosure_ranges(app, scratch, buffer, pos, flags); if (ranges.count > 0){ int32_t marker_count = ranges.count*2; Marker *markers = push_array(scratch, Marker, marker_count); Marker *marker = markers; Range *range = ranges.ranges; for (int32_t i = 0; i < ranges.count; i += 1, range += 1, marker += 2){ marker[0].pos = range->first; marker[1].pos = range->one_past_last - 1; } Managed_Object o = alloc_buffer_markers_on_buffer(app, buffer->buffer_id, marker_count, &render_scope); managed_object_store_data(app, o, 0, marker_count, markers); Marker_Visual_Take_Rule take_rule = {0}; take_rule.take_count_per_step = 2; take_rule.step_stride_in_marker_count = 8; int32_t first_color_index = (ranges.count - 1)%color_count; for (int32_t i = 0, color_index = first_color_index; i < color_count; i += 1){ Marker_Visual visual = create_marker_visual(app, o); int_color back = SymbolicColor_Transparent; int_color fore = SymbolicColor_Default; if (back_colors != 0){ back = back_colors[color_index]; } if (fore_colors != 0){ fore = fore_colors[color_index]; } marker_visual_set_effect(app, visual, type, back, fore, 0); take_rule.first_index = i*2; marker_visual_set_take_rule(app, visual, take_rule); color_index = color_index - 1; if (color_index < 0){ color_index += color_count; } } } end_temp_memory(temp); }
void depth_first(ELE tos) { int i; if(in_array(finished, findex, tos->val)) { return; } printf("%d ", tos->val); stk=push_stack(stk, tos); push_array(finished, &findex, tos->val); for(i=0;i<=tos->n_child;i++) { depth_first(tos->child[i]); } stk=pop_stack(stk); }
static void initialize_data(uint32_t memsize, uint32_t num_particles_x, uint32_t num_particles_y, uint32_t num_levels, uint32_t num_coeffs) { uint32_t num_particles = num_particles_x * num_particles_y; memory.free_memory = (uint8_t*)calloc(memsize, 1); memory.free_memory_size = memsize; data.positions = push_array(v2, num_particles); data.velocities = push_array(v2, num_particles); data.forces = push_array(v2, num_particles); data.num_particles = num_particles; /* initialize equidistant grid */ v2 min_corner = V2(0, 0); v2 max_corner = V2(1, 1); v2 dim = max_corner - min_corner; float dx = dim.x / num_particles_x; float dy = dim.y / num_particles_y; uint32_t idx = 0; for(uint32_t j = 0; j < num_particles_y; j++) { for(uint32_t i = 0; i < num_particles_x; i++) { data.positions[idx] = min_corner + V2(i * dx, j * dy); data.velocities[idx] = V2(0,0); idx++; } } data.dim = dim; data.num_levels = num_levels; data.num_coeffs = num_coeffs; v2 half_dim = 0.5f * data.dim; initialize_quad_tree(&data.root_cell, half_dim, half_dim, num_levels, num_coeffs); }
int pr_parser_server_ctxt_push(server_rec *s) { if (s == NULL) { errno = EINVAL; return -1; } if (parser_servstack == NULL) { errno = EPERM; return -1; } parser_curr_server = (server_rec **) push_array(parser_servstack); *parser_curr_server = s; return 0; }
void RTTIBuilder::push_array(llvm::Constant * CI, uint64_t dim, Type* valtype, Dsymbol * mangle_sym) { std::string tmpStr(valtype->arrayOf()->toChars()); tmpStr.erase( remove( tmpStr.begin(), tmpStr.end(), '[' ), tmpStr.end() ); tmpStr.erase( remove( tmpStr.begin(), tmpStr.end(), ']' ), tmpStr.end() ); tmpStr.append("arr"); std::string initname(mangle_sym?mangle_sym->mangle():".ldc"); initname.append(".rtti."); initname.append(tmpStr); initname.append(".data"); LLGlobalVariable* G = new llvm::GlobalVariable( *gIR->module, CI->getType(), true, TYPEINFO_LINKAGE_TYPE, CI, initname); G->setAlignment(valtype->alignsize()); push_array(dim, DtoBitCast(G, DtoType(valtype->pointerTo()))); }
/* * _sql_add_connection: internal helper function to maintain a cache of * connections. Since we expect the number of named connections to * be small, simply use an array header to hold them. We don't allow * duplicate connection names. * * Returns: NULL if the insertion was unsuccessful, a pointer to the * conn_entry_t that was created if successful. */ static void *_sql_add_connection(pool *p, char *name, db_conn_t *conn) { conn_entry_t *entry = NULL; if ((!name) || (!conn) || (!p)) return NULL; if (_sql_get_connection(name)) { /* duplicated name */ return NULL; } entry = (conn_entry_t *) pcalloc(p, sizeof(conn_entry_t)); entry->name = name; entry->data = conn; *((conn_entry_t **) push_array(conn_cache)) = entry; return entry; }
static void open_jump_lister(Application_Links *app, Partition *scratch, Heap *heap, View_Summary *ui_view, Buffer_ID list_buffer_id, Jump_Lister_Activation_Rule activation_rule, View_Summary *optional_target_view){ Marker_List *list = get_or_make_list_for_buffer(app, scratch, heap, list_buffer_id); if (list != 0){ Buffer_Summary list_buffer = get_buffer(app, list_buffer_id, AccessAll); int32_t estimated_string_space_size = 0; view_end_ui_mode(app, ui_view); Temp_Memory temp = begin_temp_memory(scratch); int32_t option_count = list->jump_count; Lister_Option *options = push_array(scratch, Lister_Option, option_count); Managed_Object stored_jumps = list->jump_array; for (int32_t i = 0; i < option_count; i += 1){ Sticky_Jump_Stored stored = {0}; managed_object_load_data(app, stored_jumps, i, 1, &stored); String line = {0}; read_line(app, scratch, &list_buffer, stored.list_line, &line); options[i].string = line.str; options[i].status = 0; options[i].user_data = IntAsPtr(i); int32_t aligned_size = line.size + 1 + 7; aligned_size = aligned_size - aligned_size%8; estimated_string_space_size += aligned_size; } Jump_Lister_Parameters jump_lister_params = {0}; jump_lister_params.list_buffer_id = list_buffer_id; jump_lister_params.activation_rule = activation_rule; if (optional_target_view != 0){ jump_lister_params.target_view_id = optional_target_view->view_id; } begin_integrated_lister__basic_list(app, "Jump:", activate_jump, &jump_lister_params, sizeof(jump_lister_params), options, option_count, estimated_string_space_size, ui_view); end_temp_memory(temp); } }
MODRET handle_getgroups(cmd_rec *cmd) { const char *name; array_header *gids; name = (char *) cmd->argv[0]; if (cmd->argv[1]) { gids = (array_header *) cmd->argv[1]; } getgroups_count++; if (strcmp(name, PR_TEST_AUTH_NAME) != 0) { return PR_DECLINED(cmd); } *((gid_t *) push_array(gids)) = PR_TEST_AUTH_GID; return mod_create_data(cmd, (void *) &gids->nelts); }