mc_message _self_response_to_h(const mo obj, const char* methodname, unsigned hashval) { //we will return a struct mc_hashitem* res; mc_message tmpmsg = {nil, nil}; if(obj == nil){ error_log("_self_response_to(obj) obj is nil. return {nil, nil}\n"); return tmpmsg; } if(obj->isa == nil){ error_log("_self_response_to(obj) obj->isa is nil. return {nil, nil}\n"); return tmpmsg; } if((res=get_item_byhash(&(obj->isa->table), hashval, methodname)) != nil){ tmpmsg.object = obj; tmpmsg.addr = res->value; runtime_log("return a message[%s/%s]\n", nameof(tmpmsg.object), methodname); return tmpmsg; }else{ runtime_log("self_response_to class[%s] can not response to method[%s]\n", nameof(obj), methodname); return tmpmsg; } }
Screen_Obj *_get_parts(QSP_ARG_DECL const char *class_str) { char pmpt[BUF_LEN]; //char text[BUF_LEN]; //char label[BUF_LEN]; Screen_Obj *sop; const char *text, *label; // Why are the label and text strings saved // in these local buffers??? sprintf(pmpt,"%s label",class_str); //strcpy( label, nameof(pmpt) ); label = nameof(pmpt) ; sprintf(pmpt,"%s action text",class_str); text = nameof(pmpt) ; if( curr_panel == NULL ) return NULL; if( label == NULL ) return NULL; // a non-existent variable, for example... if( text == NULL ) return NULL; // a non-existent variable, for example... sop = simple_object(label); if( sop == NULL ) return(sop); SET_SOB_ACTION(sop, savestr(text)); return(sop); }
matrixsectassign(const M1 &a, const M2 &b) { int i,j; E c,e(n,n); testing(nameof(e),"operator &=("+nameof(a)+","+nameof(b)+")"); if(!tested()) { for(i=1;i<=n;i++) for(j=1;j<=n;j++) a[i][j]= 23-i+j,b[i][j]=1023-2*i-3*j,e[i][j]=(123-i+j)&(1023-2*i-3*j); c=(a&=b); int err=0; for(i=1;i<=n;i++) { //cout << c[i][j] << " " << a[i][j] << " " << e[i][j] << endl; for(j=1;j<=n;j++) if(c[i][j]!=e[i][j] || a[i][j]!=e[i][j]) err=1; } if(err) error(); else ok(); } }
/* * Reply to a series of messages by simply mailing to the senders * and not messing around with the To: and Cc: lists as in normal * reply. */ int doRespond(int *msgvec) { struct header head; struct message *mp; int *ap; char *cp, *mid; head.h_to = NULL; for (ap = msgvec; *ap != 0; ap++) { mp = &message[*ap - 1]; touch(mp); dot = mp; if ((cp = skin(hfield("from", mp))) == NULL) cp = skin(nameof(mp, 2)); head.h_to = cat(head.h_to, extract(cp, GTO)); mid = skin(hfield("message-id", mp)); } if (head.h_to == NULL) return (0); mp = &message[msgvec[0] - 1]; if ((head.h_subject = hfield("subject", mp)) == NULL) head.h_subject = hfield("subj", mp); head.h_subject = reedit(head.h_subject); head.h_cc = NULL; head.h_bcc = NULL; head.h_smopts = NULL; head.h_replyto = value("REPLYTO"); head.h_inreplyto = mid; mail1(&head, 1); return (0); }
mc_message _self_response_to_h(const mo obj, const char* methodname, MCHash hashval) { //we will return a struct mc_hashitem* res = mull; mc_message tmpmsg = {mull, mull}; if(obj == mull){ //no need to warning user return tmpmsg; } if(obj->isa == mull){ error_log("_self_response_to(obj, '%s') obj->isa is mull. return {mull, mull}\n", methodname); return tmpmsg; } if((res=get_item_byhash(obj->isa->table, hashval, methodname)) != mull){ tmpmsg.object = obj; tmpmsg.address = res->value.mcfuncptr; runtime_log("return a message[%s/%s]\n", nameof(obj), methodname); return tmpmsg; }else{ if (obj->nextResponder != mull) { return _self_response_to_h(obj->nextResponder, methodname, hashval); }else{ runtime_log("self_response_to class[%s] can not response to method[%s]\n", nameof(obj), methodname); if (MC_STRICT_MODE == 1) { exit(-1); }else{ return tmpmsg; } } } }
/* * Reply to a list of messages. Extract each name from the * message header and send them off to mail1() */ int dorespond(int *msgvec) { struct message *mp; char *cp, *rcv, *replyto; char **ap; struct name *np; struct header head; if (msgvec[1] != 0) { printf("Sorry, can't reply to multiple messages at once\n"); return (1); } mp = &message[msgvec[0] - 1]; touch(mp); dot = mp; if ((rcv = skin(hfield("from", mp))) == NULL) rcv = skin(nameof(mp, 1)); if ((replyto = skin(hfield("reply-to", mp))) != NULL) np = extract(replyto, GTO); else if ((cp = skin(hfield("to", mp))) != NULL) np = extract(cp, GTO); else np = NULL; np = elide(np); /* * Delete my name from the reply list, * and with it, all my alternate names. */ np = delname(np, myname); if (altnames) for (ap = altnames; *ap != NULL; ap++) np = delname(np, *ap); if (np != NULL && replyto == NULL) np = cat(np, extract(rcv, GTO)); else if (np == NULL) { if (replyto != NULL) printf("Empty reply-to field -- replying to author\n"); np = extract(rcv, GTO); } head.h_to = np; if ((head.h_subject = hfield("subject", mp)) == NULL) head.h_subject = hfield("subj", mp); head.h_subject = reedit(head.h_subject); if (replyto == NULL && (cp = skin(hfield("cc", mp))) != NULL) { np = elide(extract(cp, GCC)); np = delname(np, myname); if (altnames != 0) for (ap = altnames; *ap != NULL; ap++) np = delname(np, *ap); head.h_cc = np; } else head.h_cc = NULL; head.h_bcc = NULL; head.h_smopts = NULL; head.h_replyto = value("REPLYTO"); head.h_inreplyto = skin(hfield("message-id", mp)); mail1(&head, 1); return (0); }
static COMMAND_FUNC( do_xv_xform ) { const char *s; s=nameof("dm expression string for x-value transformation"); set_xval_xform(s); }
int _get_strings(QSP_ARG_DECL Screen_Obj *sop,const char ***sss) { const char **string_arr; int i; int n; n=(int)how_many("number of items"); if( n < 0 ){ SET_SOB_N_SELECTORS(sop,0); sprintf(ERROR_STRING,"get_strings: number of selectors must be non-negative!?"); WARN(ERROR_STRING); return -1; } // do this after returning //SET_SOB_N_SELECTORS(sop,n); /* so_action_text is set to some garbage */ if( n > 0 ){ string_arr = (const char **)getbuf( n * sizeof(char *) ); // do this after returning // SET_SOB_SELECTORS(sop,string_arr); for(i=0;i<n;i++){ string_arr[i]=savestr(nameof("selector text") ); } *sss = string_arr; } else { *sss = NULL; } return(n); }
void funclist P1 (const SYM *, sp) { if (extern_option) { put_typ (returned_type (typeof (sp))); lprintf (" %s", nameof (sp)); put_parms (parameters (typeof (sp))); lprintf (";%s", newline); } }
/* * See if the passed name sent the passed message number. Return true * if so. */ int matchsender(char *str, int mesg) { char *cp; if (!*str) /* null string matches nothing instead of everything */ return(0); cp = nameof(&message[mesg - 1], 0); return (strcasestr(cp, str) != NULL); }
static COMMAND_FUNC( do_pnt_bars ) { FILE *fp; Trial_Class *tcp; tcp = pick_trial_class(""); fp=try_nice( nameof("output file"), "w" ); if( fp == NULL || tcp == NULL ) return; pnt_bars( QSP_ARG fp, tcp ); }
int _which_one(QSP_ARG_DECL const char *prompt, int n, const char** choices) { int i; int nmatches=0; int lastmatch=(-1); /* init to elim warning */ const char *user_response; #ifdef HAVE_HISTORY check_preload(prompt, n, choices); #endif /* HAVE_HISTORY */ user_response = nameof(prompt); for(i=0;i<n;i++){ assert(choices[i]!=NULL); if( !strcmp( user_response, choices[i] ) ){ return(i); } } /* if no exact match check for substring match */ for(i=0;i<n;i++) if( is_a_substring( user_response, choices[i] ) ){ lastmatch=i; nmatches++; } if( nmatches==1 ){ sprintf(ERROR_STRING,"Unambiguous substring match of \"%s\" to \"%s\"", user_response,choices[lastmatch]); //advise(ERROR_STRING); warn(ERROR_STRING); return(lastmatch); } else if( nmatches > 1 ){ sprintf(ERROR_STRING,"ambiguous choice \"%s\"",user_response); warn(ERROR_STRING); return(-1); } sprintf(ERROR_STRING,"invalid choice \"%s\"",user_response); warn(ERROR_STRING); sprintf(ERROR_STRING,"valid selections for %s are:",prompt); advise(ERROR_STRING); for(i=0;i<n;i++){ sprintf(ERROR_STRING,"\t%s",choices[i]); advise(ERROR_STRING); } #ifdef HAVE_HISTORY if( intractive() ) rem_def(prompt,user_response) ; #endif /* HAVE_HISTORY */ return(-1); }
static COMMAND_FUNC( pntgrph ) { FILE *fp; Trial_Class *tcp; tcp = pick_trial_class(""); fp=try_nice( nameof("output file"), "w" ); if( fp == NULL || tcp == NULL ) return; if( no_data(QSP_ARG "pntgrph") ) return; pntcurve(QSP_ARG fp,tcp); }
stringbuf& operator <<(stringbuf& sb, const TransOpBase& op) { static const char* size_names[4] = {"b", "w", "d", ""}; // e.g. addfp, addfv, addfd, xxx static const char* fptype_names[4] = {".s", ".vs", ".d", ".d"}; bool ld = isload(op.opcode); bool st = isstore(op.opcode); bool fp = (isclass(op.opcode, OPCLASS_FP_ALU)); bool br = isbranch(op.opcode); stringbuf sbname; sbname << nameof(op.opcode); if (!(opinfo[op.opcode].flagops & opNOSIZE)) sbname << (fp ? fptype_names[op.size] : size_names[op.size]); if (isclass(op.opcode, OPCLASS_USECOND)) sbname << ".", cond_code_names[op.cond]; if (ld|st) { if (op.opcode == OP_mf) { static const char* mf_names[4] = {"none", "st", "ld", "all"}; sbname << '.', mf_names[op.extshift]; } sbname << ((op.cond == LDST_ALIGN_LO) ? ".lo" : (op.cond == LDST_ALIGN_HI) ? ".hi" : ""); } else if ((op.opcode == OP_mask) || (op.opcode == OP_maskb)) { sbname << ((op.cond == 0) ? "" : (op.cond == 1) ? ".z" : (op.cond == 2) ? ".x" : ".???"); } if ((ld|st) && (op.cachelevel > 0)) sbname << ".L", (char)('1' + op.cachelevel); if ((ld|st) && (op.locked)) sbname << ((ld) ? ".acq" : ".rel"); if (op.internal) sbname << ".p"; if (op.eom) sbname << ".", (op.any_flags_in_insn ? "+" : "-"); sb << padstring((char*)sbname, -12), " ", arch_reg_names[op.rd]; if ((op.rd < ARCHREG_COUNT) & (!op.final_arch_in_insn)) sb << ".t"; sb << " = "; if (ld|st) sb << "["; sb << arch_reg_names[op.ra]; if (op.rb == REG_imm) { if (abs(op.rbimm) <= 32768) sb << ",", op.rbimm; else sb << ",", (void*)op.rbimm; } else { sb << ",", arch_reg_names[op.rb]; } if (ld|st) sb << "]"; if ((op.opcode == OP_mask) | (op.opcode == OP_maskb)) { MaskControlInfo mci(op.rcimm); int sh = (op.opcode == OP_maskb) ? 3 : 0; sb << ",[ms=", (mci.info.ms >> sh), " mc=", (mci.info.mc >> sh), " ds=", (mci.info.ds >> sh), "]"; } else {
static COMMAND_FUNC( do_new_lintbl ) { Data_Obj *lt_dp; const char *s; s=nameof("name for new linearization table"); lt_dp = new_lintbl(s); if( lt_dp == NULL ) return; CHECK_DPYP("do_new_lintbl") #ifdef HAVE_X11 DPA_LINTBL_OBJ(current_dpyp) = lt_dp; #endif /* HAVE_X11 */ do_default_lin(SINGLE_QSP_ARG); }
PRIVATE void put_reference P1 (SYM *, sp) { if (!is_symbol_output (sp)) { switch (storageof (sp)) { case sc_global: nl (); oprintf ("\t.extern %s%s", outlate (nameof (sp)), newline); break; case sc_external: default: break; } symbol_output (sp); } }
static const char *storage_name(at *p) { storage_t *st = (storage_t *)Mptr(p); char *kind = ""; switch (st->kind) { case STS_NULL: kind = "unallocated"; break; case STS_MANAGED: kind = "managed"; break; case STS_FOREIGN: kind = "foreign"; break; case STS_MMAP: kind = "mmap"; break; case STS_STATIC: kind = "static"; break; default: fprintf(stderr, "internal error: invalid storage kind"); abort(); } const char *clname = nameof(Symbol(Class(p)->classname)); sprintf(string_buffer, "::%s:%s@%p:<%"PRIdPTR">", clname, kind, st->data, st->size); return mm_strdup(string_buffer); }
static COMMAND_FUNC( do_sine_mod ) { int nf,per; int nc; float phase[8]; const char *s; int i; nf=(int)how_many("number of frames"); per=(int)how_many("period in frames"); s=nameof("lut buffer name stem"); nc=get_ncomps(); for(i=0;i<nc;i++) phase[i] = (float)(i*2*atan(1)); sine_mod_amp(nf,phase,per,(float *)NULL,s); }
static COMMAND_FUNC(do_fetch_chunk) { Chunk_Data *cd_p; Data_Obj *dp; const char *s; char buf[64]; s = nameof("variable name"); cd_p = pick_chunk_data(""); dp = pick_obj("camera buffer"); if( cd_p == NULL || dp == NULL ) return; fetch_chunk_data(cd_p,dp); //display_chunk_data(cd_p); format_chunk_data(buf,cd_p); assign_var(s,buf); }
static COMMAND_FUNC( prquic ) { FILE *fp; int i; int in_db; Trial_Class *tcp; fp=try_nice( nameof("quic file"), "w"); tcp = pick_trial_class(""); in_db = ASKIF("transform x values to decibels"); if( fp == NULL || tcp == NULL ) return; if( no_data(SINGLE_QSP_ARG,"prquic") ) return; fprintf(fp,"%c\n",004); /* EOT */ pntquic(fp,tcp,in_db); fclose(fp); }
void receipt(struct message *mp) { char head[LINESIZE]; char buf[BUFSIZ]; FILE *pp, *fp; char *mail, *s; if ((mail = value("sendmail")) == 0) #ifdef SENDMAIL mail = SENDMAIL; #else mail = MAIL; #endif if (icsubstr(hfield("default-options", mp, addone), "/receipt") || icsubstr(hfield(">to", mp, addto), "/receipt")) { snprintf(buf, sizeof (buf), "%s %s", mail, skin(nameof(mp))); if (pp = npopen(buf, "w")) { headline_t *hl; if (headline_alloc(&hl) != 0) { err(1, "could not allocate memory"); } fp = setinput(mp); readline(fp, head); if (parse_headline(head, hl) != 0) { headline_reset(hl); } if (custr_len(hl->hl_date) > 0) { fprintf(pp, "Original-Date: %s\n", custr_cstr(hl->hl_date)); } if (s = hfield("message-id", mp, addone)) fprintf(pp, "Original-Message-ID: %s\n", s); s = hfield("subject", mp, addone); fprintf(pp, "Subject: RR: %s\n", s ? s : "(none)"); npclose(pp); headline_free(hl); } } }
/* * Print out the header of a specific message. * This is a slight improvement to the standard one. */ void printhead(int mesg) { struct message *mp; char headline[LINESIZE], wcount[LINESIZE], *subjline, dispc, curind; char pbuf[BUFSIZ]; struct headline hl; int subjlen; char *name; mp = &message[mesg-1]; (void)readline(setinput(mp), headline, LINESIZE); if ((subjline = hfield("subject", mp)) == NULL) subjline = hfield("subj", mp); /* * Bletch! */ curind = dot == mp ? '>' : ' '; dispc = ' '; if (mp->m_flag & MSAVED) dispc = '*'; if (mp->m_flag & MPRESERVE) dispc = 'P'; if ((mp->m_flag & (MREAD|MNEW)) == MNEW) dispc = 'N'; if ((mp->m_flag & (MREAD|MNEW)) == 0) dispc = 'U'; if (mp->m_flag & MBOX) dispc = 'M'; parse(headline, &hl, pbuf); sprintf(wcount, "%3ld/%-5ld", mp->m_lines, mp->m_size); subjlen = screenwidth - 50 - strlen(wcount); name = value("show-rcpt") != NULL ? skin(hfield("to", mp)) : nameof(mp, 0); if (subjline == NULL || subjlen < 0) /* pretty pathetic */ printf("%c%c%3d %-20.20s %16.16s %s\n", curind, dispc, mesg, name, hl.l_date, wcount); else printf("%c%c%3d %-20.20s %16.16s %s \"%.*s\"\n", curind, dispc, mesg, name, hl.l_date, wcount, subjlen, subjline); }
/* * put a constant to the output file. */ static void putconst P1 (const EXPR *, ep) { switch (ep->nodetype) { case en_autocon: case en_icon: oprintf ("%ld", ep->v.i); break; case en_labcon: oprintf ("%s%u", prefix, (unsigned) ep->v.l); break; case en_nacon: oprintf ("%s", outlate (ep->v.str)); break; case en_sym: oprintf ("%s", outlate (nameof (ep->v.sp))); break; case en_add: putconst (ep->v.p[0]); oprintf ("+"); putconst (ep->v.p[1]); break; case en_sub: putconst (ep->v.p[0]); oprintf ("-"); putconst (ep->v.p[1]); break; case en_uminus: oprintf ("-"); /*FALLTHRU */ case en_cast: putconst (ep->v.p[0]); break; case en_str: oprintf ("%s", ep->v.str); break; default: FATAL ( (__FILE__, "putconst", "illegal constant node %d", ep->nodetype)); break; } }
matrixsect(const M1 &a, const M2 &b) { int i,j; E c,e(n,n); testing(nameof(e),"operator &("+nameof(a)+","+nameof(b)+")"); if(!tested()) { for(i=1;i<=n;i++) for(j=1;j<=n;j++) a[i][j]= 23-i+j,b[i][j]=1023-2*i-3*j,e[i][j]=(23-i+j)&(1023-2*i-3*j); int err=0; c=a&b; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) if(!(c[i][j]==e[i][j] && !(c[i][j]!=e[i][j]))) err=1; } if(err) error(); else ok(); } testing(nameof(e),"operator &("+nameof(b)+","+nameof(a)+")"); if(!tested()) { for(i=1;i<=n;i++) for(j=1;j<=n;j++) a[i][j]= 23-i+j,b[i][j]=1023-2*i-3*j,e[i][j]=(23-i+j)&(1023-2*i-3*j); int err=0; c=b&a; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) if(!(c[i][j]==e[i][j] && !(c[i][j]!=e[i][j]))) err=1; } if(err) error(); else ok(); } }
static COMMAND_FUNC( do_read_data ) /** read a data file */ { FILE *fp; const char *filename; char num_str[16]; filename=nameof("data file"); fp=try_open( filename, "r" ); if( !fp ) return; /* We used to clear the data tables here, * but now they are dynamically allocated * and cleared at that time... */ /* clear old classes */ do_delete_all_classes(SINGLE_QSP_ARG); //curr_tcp=NULL; n_have_classes=0; if( read_exp_data(QSP_ARG fp) != 0 ){ fclose(fp); sprintf(ERROR_STRING,"do_read_data: error return from read_exp_data, file %s",filename); WARN(ERROR_STRING); return; } fclose(fp); n_have_classes = eltcount(class_list()); sprintf(num_str,"%d",n_have_classes); // BUG? buffer overflow // if n_have_classes too big??? assign_reserved_var( "n_classes" , num_str ); if( verbose ){ sprintf(ERROR_STRING,"File %s read, %d classes, %d x-values", filename,n_have_classes,_nvals); advise(ERROR_STRING); } }
void dumpsyms(Biobuf *b) { Sym *s; Type *t; for(s=symbols; s; s=s->next){ t = s->type; t = defer(t); if(t->ty == Pointer){ t = t->sub; if(t && t->equiv) t = t->equiv; } if(t == nil || t->ty != Aggr) continue; Bprint(b, "complex %B %B%s%B;\n", nameof(t, 1), s->fn ? fixname(s->fn) : "", s->fn ? ":" : "", fixname(s->name)); } symbols = nil; lsym = &symbols; }
static int ref_count_down(MCObject* const obj) { for (;;) { if (obj == null) { error_log("recycle/release(null) do nothing.\n"); return REFCOUNT_ERR; } if (obj->ref_count == 0) { runtime_log("recycle/release(%s) count=0 return\n", nameof(obj)); return REFCOUNT_ERR; } if (obj->ref_count == REFCOUNT_NO_MM) { debug_log("ref_count is REFCOUNT_NO_MM manage by runtime. do nothing\n"); return REFCOUNT_NO_MM; } if (obj->isa == null) { error_log("recycle/release(obj) obj have no class linked. do nothing.\n"); return REFCOUNT_ERR; } #ifdef NO_ATOMIC obj->ref_count--; break; #else int oldcount, newcount; int *addr; addr = &(this->ref_count); oldcount = mc_atomic_get_integer(addr); newcount = oldcount; if (newcount > 0) newcount--; if (!mc_atomic_set_integer(addr, oldcount, newcount)) break; #endif } return obj->ref_count; }
static void _get_dummy_input(SINGLE_QSP_ARG_DECL) { const char *s; s = nameof("input value (will not be used)"); if( s != NULL ) s=NULL; // silence compiler }
void generate_def_file(cmd_data_t *cmd_data) { char def_file[1024]; char implib_file[1024]; char *ext; FILE *hDef; char *export_args[1024]; int num_export_args = 0; char *cmd; int cmd_size = 0; int a; if (cmd_data->output_name) { strcpy(def_file, cmd_data->output_name); strcat(def_file, ".def"); hDef = fopen(def_file, "w"); if (hDef != NULL) { fprintf(hDef, "LIBRARY '%s' INITINSTANCE\n", nameof(cmd_data->output_name)); fprintf(hDef, "DATA NONSHARED\n"); fprintf(hDef, "EXPORTS\n"); fclose(hDef); for (a=0; a < cmd_data->num_obj_files; a++) { cmd_size += strlen(cmd_data->obj_files[a]) + 1; } cmd_size += strlen(GEN_EXPORTS) + strlen(def_file) + 3; cmd = (char *)malloc(cmd_size); strcpy(cmd, GEN_EXPORTS); for (a=0; a < cmd_data->num_obj_files; a++) { strcat(cmd, " "); strcat(cmd, cmd_data->obj_files[a] ); } strcat(cmd, ">>"); strcat(cmd, def_file); puts(cmd); export_args[num_export_args++] = SHELL_CMD; export_args[num_export_args++] = "-c"; export_args[num_export_args++] = cmd; export_args[num_export_args++] = NULL; spawnvp(P_WAIT, export_args[0], export_args); cmd_data->arglist[cmd_data->num_args++] = strdup(def_file); /* Now make an import library for the dll */ num_export_args = 0; export_args[num_export_args++] = DEF2IMPLIB_CMD; export_args[num_export_args++] = "-o"; strcpy(implib_file, ".libs/"); strcat(implib_file, cmd_data->stub_name); ext = strrchr(implib_file, '.'); if (ext) *ext = 0; strcat(implib_file, "."); strcat(implib_file, STATIC_LIB_EXT); export_args[num_export_args++] = implib_file; export_args[num_export_args++] = def_file; export_args[num_export_args++] = NULL; spawnvp(P_WAIT, export_args[0], export_args); } } }
/* * generate a named label. */ PRIVATE void put_name P1 (SYM *, sp) { put_reference (sp); oprintf ("%s:%s", outlate (nameof (sp)), newline); }