static error_t parse_opt(int key, char *arg, struct argp_state *state) { struct opts *opts = state->input; switch (key) { case 'a': new_op(opts, OPT_OP_ADD, arg); break; case 'r': new_op(opts, OPT_OP_REM, arg); break; case 'j': opts->journal_resume = true; break; case 'b': opts->journal_abort = true; break; case ARGP_KEY_END: if (!opts->journal_abort && !opts->journal_resume && opts->ops_cnt == 0) argp_error(state, "No operation specified. Please specify what to do."); break; default: return ARGP_ERR_UNKNOWN; }; if (opts->journal_abort && opts->journal_resume) argp_error(state, "Aborting and resuming journal at the same time is not possible."); return 0; }
static int op_simple(struct ParseCtx *ctx, enum OpType t) { struct Op *op = new_op(ctx, t, 0); if (!op) return REG_ESPACE; return 0; }
static int op_gstart(struct ParseCtx *ctx) { struct Op *op; op = new_op(ctx, OP_GROUP, sizeof(struct GroupData)); if (!op) return REG_ESPACE; if (op->grp_no >= MAX_GROUPS) return REG_BADPAT; return 0; }
static int op_char(struct ParseCtx *ctx, unsigned c) { struct Op *op = new_op(ctx, OP_CHAR, 0); if (!op) return REG_ESPACE; op->lit = c; if ((ctx->rxi->flags & REG_ICASE) && isalpha(c)) op->lit = tolower(c); return 0; }
int main(int argc,char**argv) { int sig,pid; union sigval bug; bug.sival_int=0; // bug.sival_ptr=NULL; sig=atoi(argv[1]); pid=atoi(argv[2]); while(1){ if(sigqueue(pid,sig,bug) < 0) printf("seng sigal error\n"); new_op(sig); } return 0; }
void sv_oper(char **cmds, t_env *e, t_fd *cl) { t_user *op; if (!cmds[0] || !cmds[1]) return (sv_err(ERR_NEEDMOREPARAMS, NULL, NULL, cl)); op = e->conf.opers; while (op) { if (!ft_strcmp(op->hostname, cl->i.host) && !ft_strcmp(op->nick, cmds[0])) { if (!ft_strcmp(op->passwd, cmds[1])) return (new_op(op, cl)); return (sv_err(ERR_PASSWDMISMATCH, NULL, NULL, cl)); } op = op->next; } sv_err(ERR_NOOPERHOST, NULL, NULL, cl); }
static int op_bref(struct ParseCtx *ctx, unsigned c) { struct Op *g, *op; op = new_op(ctx, OP_BREF, 0); if (!op) return REG_ESPACE; op->bref = c - '0'; /* check if valid ref */ for (g = ctx->last_group; g; g = g->gdata.parent) { if (g->grp_no == op->bref) return REG_ESUBREG; } /* tag the group as referenced */ for (g = ctx->rxi->glist; g; g = g->gdata.glist_prev) { if (g->grp_no == op->bref) { g->gdata.has_refs = true; return 0; } } return REG_ESUBREG; }
void mpi_init_(int* ierr) { if(!comm_lookup){ comm_lookup = xbt_dynar_new(sizeof(MPI_Comm), NULL); new_comm(MPI_COMM_WORLD); group_lookup = xbt_dynar_new(sizeof(MPI_Group), NULL); request_lookup = xbt_dict_new_homogeneous(NULL); datatype_lookup = xbt_dynar_new(sizeof(MPI_Datatype), NULL); new_datatype(MPI_BYTE); new_datatype(MPI_CHAR); new_datatype(MPI_INT); new_datatype(MPI_INT); new_datatype(MPI_INT8_T); new_datatype(MPI_INT16_T); new_datatype(MPI_INT32_T); new_datatype(MPI_INT64_T); new_datatype(MPI_FLOAT); new_datatype(MPI_FLOAT); new_datatype(MPI_DOUBLE); new_datatype(MPI_DOUBLE); new_datatype(MPI_C_FLOAT_COMPLEX); new_datatype(MPI_C_DOUBLE_COMPLEX); new_datatype(MPI_2INT); new_datatype(MPI_UINT8_T); new_datatype(MPI_UINT16_T); new_datatype(MPI_UINT32_T); new_datatype(MPI_UINT64_T); new_datatype(MPI_2FLOAT); new_datatype(MPI_2DOUBLE); op_lookup = xbt_dynar_new(sizeof(MPI_Op), NULL); new_op(MPI_MAX); new_op(MPI_MIN); new_op(MPI_MAXLOC); new_op(MPI_MINLOC); new_op(MPI_SUM); new_op(MPI_PROD); new_op(MPI_LAND); new_op(MPI_LOR); new_op(MPI_LXOR); new_op(MPI_BAND); new_op(MPI_BOR); new_op(MPI_BXOR); } /* smpif2c is responsible for generating a call with the final arguments */ *ierr = MPI_Init(NULL, NULL); }
static cell_t *read_token(secd_t *secd, secd_parser_t *p) { int tok; cell_t *inp = NULL; switch (tok = p->token) { case '(': ++p->nested; inp = read_list(secd, p); if (p->token != ')') goto error_exit; return inp; case TOK_NUM: return new_number(secd, p->numtok); case TOK_CHAR: return new_char(secd, p->numtok); case TOK_SYM: return new_symbol(secd, p->symtok); case TOK_STR: inp = new_string(secd, strmem(p->strtok)); drop_cell(secd, p->strtok); return inp; case TOK_EOF: return new_symbol(secd, EOF_OBJ); case TOK_QUOTE: case TOK_QQ: case TOK_UQ: case TOK_UQSPL: { const char *formname = special_form_for(tok); assert(formname, "No special form for token=%d\n", tok); inp = sexp_read(secd, p); assert_cell(inp, "sexp_read: reading subexpression failed"); return new_cons(secd, new_symbol(secd, formname), new_cons(secd, inp, SECD_NIL)); } case '#': switch (tok = lexnext(p)) { case '(': { cell_t *tmplist = read_list(secd, p); if (p->token != ')') { free_cell(secd, tmplist); goto error_exit; } inp = list_to_vector(secd, tmplist); free_cell(secd, tmplist); return inp; } case TOK_SYM: { if (p->symtok[0] == '.') { int op = secdop_by_name(p->symtok + 1); if (op < 0) goto error_exit; return new_op(secd, op); } if (str_eq(p->symtok, "u8")) { lexnext(p); inp = read_bytevector(p); if (p->token != ')') goto error_exit; return inp; } } } errorf("Unknown suffix for #\n"); } error_exit: if (inp) free_cell(secd, inp); errorf("read_token: failed\n"); return new_error(secd, SECD_NIL, "read_token: failed on token %1$d '%1$c'", p->token); }
void otbl_init() /* operator representation table */ { new_op("->",REF); new_op("." ,DOT); new_op("!" ,NOT); new_op("~" ,COMPL); new_op("++",INCR); new_op("--",DECR); new_op("*" ,MUL); new_op("&" ,AND); new_op("&" ,ADDROF); new_op("&" ,G_ADDROF); new_op("/" ,DIV); new_op("%" ,MOD); new_op("+" ,PLUS); new_op("-" ,MINUS); new_op("-" ,UMINUS); new_op("<<",LS); new_op(">>",RS); new_op("<" ,LT); new_op(">" ,GT); new_op("<=",LE); new_op(">=",GE); new_op("==",EQ); new_op("!=",NE); new_op("^" ,ER); new_op("|" ,OR); new_op("&&",ANDAND); new_op("||",OROR); new_op("?" ,QUEST); new_op(":" ,COLON); new_op("=" ,ASSIGN); new_op("," ,CM); new_op(";" ,SM); new_op("{" ,LC); new_op("}" ,RC); new_op("(" ,LP); new_op(")" ,RP); new_op("[" ,LB); new_op("]" ,RB); new_op("+=",ASPLUS); new_op("-=",ASMINUS); new_op("*=",ASMUL); new_op("/=",ASDIV); new_op("%=",ASMOD); new_op("&=",ASAND); new_op("|=",ASOR); new_op("^=",ASER); new_op(">>=",ASRS); new_op("<<=",ASLS); new_op("sizeof",SIZEOF); new_op("new",NEW); new_op("delete",DELETE); new_op("0" ,ZERO); new_op("," ,ELIST); new_op("[]" ,DEREF); new_op("expression list", ELIST); new_op("function call", CALL); new_op("generated function call",G_CALL); new_op("inline function call",ICALL); new_op("cast",CAST); new_op("inline argument",ANAME); new_op("class", COBJ); new_op("enum", EOBJ); new_op("union", ANON); new_op("function",FCT); new_op("pointer",PTR); new_op("reference",RPTR); new_op("vector",VEC); new_op("identifier",ID); new_op("name",NAME); new_op("...",ELLIPSIS); new_op("::",MEM); new_op("type name",TYPE); new_op("{}",BLOCK); new_op("pair",PAIR); new_op("declaration",DCL); new_op("character constant",CCON); new_op("integer constant",ICON); new_op("float constant",FCON); new_op("string",STRING); }
struct atom *new_op0(u8 op_code) { struct atom *atom; atom = new_op(op_code, ATOM_TYPE_OP_ARG_NONE, NULL); return atom; }
struct TOp new_xor(int op1, int op2) { return new_op(op1, op2, '^', &_xor); }
struct TOp new_or(int op1, int op2) { return new_op(op1, op2, '|', &_or); }
struct TOp new_and(int op1, int op2) { return new_op(op1, op2, '&', &_and); }
static int op_class(struct ParseCtx *ctx, const char **re) { const char *s = *re; struct ClassData *cd; struct Op *op; bool not = false, icase = ctx->rxi->flags & REG_ICASE; const char *start; unsigned tk, c, prevtk = 0; bool is_range = false; int err; if (*s == '^') { s++; not = true; } start = s; op = new_op(ctx, OP_CLASS, sizeof(struct ClassData)); if (!op) return REG_ESPACE; cd = &op->cdata; if (not && (ctx->rxi->flags & REG_NEWLINE)) class_set(cd, '\n'); while (*s) { err = get_map_token(ctx, &s, &tk, s == start, cd, icase); if (err) return err; if (tk == MAP_END) { if (prevtk) add_char(cd, prevtk, icase); goto done; } else if (tk == MAP_OTHER) { if (is_range) return REG_ERANGE; if (prevtk) add_char(cd, prevtk, icase); prevtk = 0; } else if (tk == MAP_RANGE) { if (!prevtk) return REG_ERANGE; is_range = true; } else if (is_range) { if (tk < prevtk) return REG_ERANGE; for (c = prevtk; c <= tk; c++) add_char(cd, c, icase); is_range = false; prevtk = 0; } else { if (prevtk) add_char(cd, prevtk, icase); prevtk = tk; } } return REG_EBRACK; done: *re = s; if (not) class_negate(cd); return 0; }