void recinit(unsigned int n) { record = (char *) malloc(n); fields = (char *) malloc(n); fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *)); if (record == NULL || fields == NULL || fldtab == NULL) FATAL("out of space for $0 and fields"); fldtab[0] = (Cell *) malloc(sizeof (Cell)); *fldtab[0] = dollar0; fldtab[0]->sval = record; fldtab[0]->nval = tostring("0"); makefields(1, nfields); }
void makefields(int n1, int n2) /* create $n1..$n2 inclusive */ { char temp[50]; int i; for (i = n1; i <= n2; i++) { fldtab[i] = (Cell *) malloc(sizeof (struct Cell)); if (fldtab[i] == NULL) FATAL("out of space in makefields %d", i); *fldtab[i] = dollar1; snprintf(temp, sizeof temp, "%d", i); fldtab[i]->nval = tostring(temp); } }
std::string FSM::GetEdgesString (int curstate) { std::string retval="\n"; if (nodes.size()<=curstate) { fprintf(stderr,"Error with faction relationship due to %d not being in range of faction\n",curstate); return "\n1. Transmit Error\n2. Transmit Error\n3. Transmit Error\n"; } for (unsigned int i=0;i<nodes[curstate].edges.size();i++) { retval+= tostring ((int)((i+1)%10))+"."+nodes[nodes[curstate].edges[i]].messages[0]+"\n"; } static bool print_docking=XMLSupport::parse_bool(vs_config->getVariable("graphics","hud","print_request_docking","true")); if (print_docking) retval+= "0. Request Docking Clearence"; return retval; }
Node *primary(void) { Node *np; switch (rtok) { case CHAR: np = op2(CHAR, NIL, itonp(rlxval)); rtok = relex(); return (unary(np)); case ALL: rtok = relex(); return (unary(op2(ALL, NIL, NIL))); case EMPTYRE: rtok = relex(); return (unary(op2(ALL, NIL, NIL))); case DOT: rtok = relex(); return (unary(op2(DOT, NIL, NIL))); case CCL: np = op2(CCL, NIL, (Node*) cclenter((char *) rlxstr)); rtok = relex(); return (unary(np)); case NCCL: np = op2(NCCL, NIL, (Node *) cclenter((char *) rlxstr)); rtok = relex(); return (unary(np)); case '^': rtok = relex(); return (unary(op2(CHAR, NIL, itonp(HAT)))); case '$': rtok = relex(); return (unary(op2(CHAR, NIL, NIL))); case '(': rtok = relex(); if (rtok == ')') { /* special pleading for () */ rtok = relex(); return unary(op2(CCL, NIL, (Node *) tostring(""))); } np = regexp(); if (rtok == ')') { rtok = relex(); return (unary(np)); } else FATAL("syntax error in regular expression %s at %s", lastre, prestr); default: FATAL("illegal primary in regular expression %s at %s", lastre, prestr); } return 0; /*NOTREACHED*/ }
string Weapon::showXml () const { CMarkup xml; xml.AddElem("weapon"); xml.IntoElem(); addBaseValues(xml); xml.AddElem("loaded_cliptype", loaded_cliptype_); xml.AddElem("ammo", tostring(ammo_)); return xml.GetDoc(); }
Cell *copycell(Cell *x) /* make a copy of a cell in a temp */ { Cell *y; y = gettemp(); y->csub = CCOPY; /* prevents freeing until call is over */ y->nval = x->nval; /* BUG? */ if (isstr(x)) y->sval = tostring(x->sval); y->fval = x->fval; y->tval = x->tval & ~(CON|FLD|REC|DONTFREE); /* copy is not constant or field */ /* is DONTFREE right? */ return y; }
static value_t fl_path_cwd(value_t *args, uint32_t nargs) { if (nargs > 1) argcount("path.cwd", nargs, 1); if (nargs == 0) { char buf[1024]; get_cwd(buf, sizeof(buf)); return string_from_cstr(buf); } char *ptr = tostring(args[0], "path.cwd"); if (set_cwd(ptr)) lerrorf(IOError, "path.cwd: could not cd to %s", ptr); return FL_T; }
static value_t fl_time_fromstring(value_t *args, uint32_t nargs) { #if defined WIN32 return 0; #else argcount("time.fromstring", nargs, 1); char *ptr = tostring(args[0], "time.fromstring"); double t = parsetime(ptr); int64_t it = (int64_t)t; if ((double)it == t && fits_fixnum(it)) return fixnum(it); return mk_double(t); #endif }
int main(){ int i; char buffer[100]; printf("Please enter an integer\n"); getLine(buffer, 100); i = tonumber (buffer); buffer[0] = '\0'; tostring(i, buffer); printf("The number is %s \n", buffer); return 0; }
char *cclenter(const char *argp) /* add a character class */ { int i, c, c2; int j; uschar *p = (uschar *) argp; uschar *op, *bp; static uschar *buf = 0; static int bufsz = 100; op = p; if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL) FATAL("out of space for character class [%.10s...] 1", p); bp = buf; for (i = 0; (c = *p++) != 0; ) { if (c == '\\') { c = quoted(&p); } else if (c == '-' && i > 0 && bp[-1] != 0) { if (*p != 0) { c = bp[-1]; c2 = *p++; if (c2 == '\\') c2 = quoted(&p); if (collate_range_cmp(c, c2) > 0) { bp--; i--; continue; } for (j = 0; j < NCHARS; j++) { if ((collate_range_cmp(c, j) > 0) || collate_range_cmp(j, c2) > 0) continue; if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter1")) FATAL("out of space for character class [%.10s...] 2", p); *bp++ = j; i++; } continue; } } if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter2")) FATAL("out of space for character class [%.10s...] 3", p); *bp++ = c; i++; } *bp = 0; dprintf( ("cclenter: in = |%s|, out = |%s|\n", op, buf) ); xfree(op); return (char *) tostring((char *) buf); }
static int api_hexchat_unhook(lua_State *L) { hook_info **info = (hook_info **)luaL_checkudata(L, 1, "hook"); if(*info) { unregister_hook(*info); *info = 0; return 0; } else { tostring(L, 1); return luaL_error(L, "hook %s is already unhooked", lua_tostring(L, -1)); } }
UOSkill::UOSkill( const Package* pkg, ConfigElem& elem ) : inited(true), skillid( strtoul( elem.rest(), NULL, 10 ) ), attributename(elem.remove_string( "Attribute", "" )), pAttr(NULL), pkg(pkg) { if (skillid < 0 || skillid >= 500) elem.throw_error( "SkillID must be < 500" ); if (!attributename.empty()) { bool required = false; if (attributename[0] == '+') { required = true; attributename = attributename.substr( 1, std::string::npos ); } pAttr = FindAttribute( attributename ); if (!pAttr) { if (required) { elem.throw_error( "Attribute " + tostring(attributename) + " not found." ); } else { elem.warn( "Attribute " + tostring(attributename) + " not found." ); } } } }
char *setsval(register cell *vp, const char *s) { dprintf("setsval: %lo %s\n", (long)vp, s); checkval(vp); if (vp == recloc) error(FATAL, "can't set $0"); vp->tval &= ~NUM; vp->tval |= STR; if ((vp->tval & FLD) && isnull(vp->nval)) donerec = 0; if (!(vp->tval&FLD)) strfree(vp->sval); vp->tval &= ~FLD; return(vp->sval = tostring(s)); }
void luaV_concat (lua_State *L, int total, int last) { do { StkId top = L->base + last + 1; int n = 2; /* number of elements handled in this pass (at least 2) */ if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) luaG_concaterror(L, top-2, top-1); } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ (void)tostring(L, top - 2); /* result is first op (as string) */ else { /* at least two string values; get as many as possible */ size_t tl = tsvalue(top-1)->len; char *buffer; int i; /* collect total length */ for (n = 1; n < total && tostring(L, top-n-1); n++) { size_t l = tsvalue(top-n-1)->len; if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); tl += l; } buffer = luaZ_openspace(L, &G(L)->buff, tl); tl = 0; for (i=n; i>0; i--) { /* concat all strings */ size_t l = tsvalue(top-i)->len; memcpy(buffer+tl, svalue(top-i), l); tl += l; #if LUA_REFCOUNT luarc_cleanvalue(top-i); #endif /* LUA_REFCOUNT */ } setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); } total -= n-1; /* got `n' strings to create 1 new */ last -= n-1; } while (total > 1); /* repeat until only 1 result left */ }
Cell *awksprintf(Node **a, int n) /* sprintf(a[0]) */ { Cell *x; Node *y; char buf[3*RECSIZE]; y = a[0]->nnext; x = execute(a[0]); if (format(buf, sizeof buf, getsval(x), y) == -1) ERROR "sprintf string %.30s... too long", buf FATAL; tempfree(x); x = gettemp(); x->sval = tostring(buf); x->tval = STR; return(x); }
//MYCONTACT void MyContact::OnChange(int prop){ if (prop == Contact::P_AVAILABILITY) { SEString name; if (!GetPropDisplayname(name)) throw SkypeException("Can't obtain display name.\n"); Contact::AVAILABILITY availability; if (!GetPropAvailability(availability)) throw SkypeException("Can't obtain availability status.\n"); SEString statusAsText; statusAsText = tostring(availability); printf("[SKYPE]: %s -> %s\n", (const char*)name, (const char*)statusAsText); }; }
static int api_hexchat_print(lua_State *L) { int i, args = lua_gettop(L); luaL_Buffer b; luaL_buffinit(L, &b); for(i = 1; i <= args; i++) { if(i != 1) luaL_addstring(&b, " "); tostring(L, i); luaL_addvalue(&b); } luaL_pushresult(&b); hexchat_print(ph, lua_tostring(L, -1)); return 0; }
bool ProcScreenName( void ) /*************************/ { if( !GetToken( SEP_NO, TOK_INCLUDE_DOT ) ) { return( false ); } if( Token.len > MAX_SCREEN_NAME_LENGTH ) { LnkMsg( LOC+LINE+WRN+MSG_VALUE_TOO_LARGE, "s", "screenname" ); } else { if( FmtData.u.nov.screenname != NULL ) { _LnkFree( FmtData.u.nov.screenname ); // assume second is correct. } FmtData.u.nov.screenname = tostring(); } return( true ); }
void AccountEx::OnChange(int prop) { if (prop == Account::P_STATUS) { Account::STATUS loginStatus; this->GetPropStatus(loginStatus); if (loginStatus == Account::LOGGED_IN) { // printf("Login complete.\n"); m_LoggedIn = true; } else if (loginStatus == Account::LOGGED_OUT) { Account::LOGOUTREASON whyLogout; this->GetPropLogoutreason(whyLogout); printf("%s\n", (const char*)tostring(whyLogout)); m_LoggedOut = true; printf("Logout complete.\n"); } } }
static int cyrussasl_sasl_server_start(lua_State *l) { int numargs = lua_gettop(l); int err; struct _sasl_ctx *ctx = NULL; const char *mech = NULL; const char *data = NULL; size_t len; unsigned outlen; if (numargs != 3) { lua_pushstring(l, "usage: " "(err, data) = cyrussasl.server_start(conn, mech, data)"); lua_error(l); return 0; } /* Pull arguments off of the stack... */ ctx = get_context(l, 1); mech = tostring(l, 2); /* Allow the 'data' param to be nil, or an empty string. */ if ( lua_type(l, 3) == LUA_TNIL ) { data = NULL; len = 0; } else { data = tolstring(l, 3, &len); } err = sasl_server_start( ctx->conn, /* saved sasl connection */ mech, /* mech, which the client chose */ data, /* data that the client sent */ len, /* length of the client's data */ &data, /* data with which the server will reply */ &outlen /* size of the server's reply */ ); /* Form the reply and push onto the stack */ lua_pushinteger(l, err); /* SASL_CONTINUE, SASL_OK, et al */ if (data) { lua_pushlstring(l, data, outlen); /* server's reply to the client */ } else { lua_pushnil(l); } return 2; /* returning 2 items on Lua stack */ }
void load_skill_entry( const Package* pkg, ConfigElem& elem ) { UOSkill uoskill( pkg, elem ); if ( uoskill.skillid >= uo_skills.size() ) uo_skills.resize( uoskill.skillid+1 ); if ( uo_skills[uoskill.skillid].inited ) { elem.throw_error( "UOSkill " + tostring(uoskill.skillid) + " already defined by " + uo_skills[uoskill.skillid].pkg->desc() ); } uo_skills[ uoskill.skillid ] = uoskill; }
char *cclenter(const char *argp) /* add a character class */ { int i, c, c2; uschar *p = (uschar *) argp; uschar *op, *bp; static uschar *buf = 0; static int bufsz = 100; op = p; if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL) FATAL("out of space for character class [%.10s...] 1", p); bp = buf; for (i = 0; (c = *p++) != 0; ) { if (c == '\\') { c = quoted((char **) &p); } else if (c == '-' && i > 0 && bp[-1] != 0) { if (*p != 0) { c = bp[-1]; c2 = *p++; if (c2 == '\\') c2 = quoted((char **) &p); if (c > c2) { /* empty; ignore */ bp--; i--; continue; } while (c < c2) { if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter1")) FATAL("out of space for character class [%.10s...] 2", p); *bp++ = ++c; i++; } continue; } } if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter2")) FATAL("out of space for character class [%.10s...] 3", p); *bp++ = c; i++; } *bp = 0; dprintf( ("cclenter: in = |%s|, out = |%s|\n", op, buf) ); xfree(op); return (char *) tostring((char *) buf); }
static value_t fl_path_cwd(value_t *args, uint32_t nargs) { uv_err_t err; if (nargs > 1) argcount("path.cwd", nargs, 1); if (nargs == 0) { char buf[1024]; err = uv_cwd(buf, sizeof(buf)); if (err.code != UV_OK) lerrorf(IOError, "path.cwd: could not get cwd: %s", uv_strerror(err)); return string_from_cstr(buf); } char *ptr = tostring(args[0], "path.cwd"); err = uv_chdir(ptr); if (err.code != UV_OK) lerrorf(IOError, "path.cwd: could not cd to %s: %s", ptr, uv_strerror(err)); return FL_T; }
parse_result parse_ipv4addr(char const * str) { parse_result addr[4]; addr[0]=parse_int_dec(str); addr[1]=parse_int_dec(addr[0].rest+1); addr[2]=parse_int_dec(addr[1].rest+1); addr[3]=parse_int_dec(addr[2].rest+1); if ( addr[0].result && in_range(*(int*)addr[0].result, 0, 256) && addr[1].result && in_range(*(int*)addr[1].result, 0, 256) && addr[2].result && in_range(*(int*)addr[2].result, 0, 256) && addr[3].result && in_range(*(int*)addr[3].result, 0, 256) && addr[0].rest && (*addr[0].rest=='.') && addr[1].rest && (*addr[1].rest=='.') && addr[2].rest && (*addr[2].rest=='.')) { size_t len=addr[3].rest-str+1; return make_parse_result(tostring(take_string(len, fullstr(str))), addr[3].rest); } else return make_parse_result(NULL, str); }
/* data = cyrussasl.decode64(b64data) * * Partner function to encode64(). */ static int cyrussasl_sasl_decode64(lua_State *l) { const char *data = NULL; char *outdata = NULL; size_t len; unsigned outlen; int err; int numargs = lua_gettop(l); if (numargs != 1) { lua_pushstring(l, "usage: data = cyrussasl.decode64(b64data)"); lua_error(l); return 0; } data = tostring(l, 1); len = strlen(data); outdata = malloc(len); if (!outdata) { lua_pushstring(l, "failed to malloc in decode64"); lua_error(l); return 0; } /* Perform a decode-in-place, which is kosher according to docs. */ err = sasl_decode64(data, len, outdata, len, &outlen); if ( err != SASL_OK ) { free(outdata); lua_pushstring(l, "sasl_decode64 failed"); lua_error(l); return 0; } if (outdata) { lua_pushlstring(l, outdata, outlen); } else { lua_pushnil(l); } free(outdata); return 1; }
void definition(char *s) /* collect definition for s and install */ /* char *s; definitions picked up lexically */ { char *p; struct symtab *stp; p = delimstr("definition"); stp = lookup(s); if (stp == NULL) /* it's not there already */ stp = newvar(tostring(s), DEFNAME); else { if (stp->s_type != DEFNAME) { yyerror("%s used as variable and definition", s); return; } free(stp->s_val.p); } stp->s_val.p = p; }
/** * [bvAdd description] * @param root [description] * @param pos [description] * @return [description] */ Node* bvAdd(Node* root, int pos) { Node* p = root; //string strL, strR; //strL = data1[pos][p->left->index]; //strR = data1[pos][p->right->index]; string pNode = tostring("v"); data1[pos].push_back(pNode); int index = data1[pos].size(); createAddTree(p, index, pos); p->oprtype = 1; p->index = index-1; p->left = NULL; p-> right = NULL; return p; }
void copy(void) /* begin input from file, etc. */ { FILE *fin; if (newfile) { if ((fin = fopen(newfile, "r")) == NULL) ERROR "can't open file %s", newfile FATAL; curfile++; curfile->fin = fin; curfile->fname = tostring(newfile); curfile->lineno = 0; printf(".lf 1 %s\n", curfile->fname); pushsrc(File, curfile->fname); newfile = 0; } if (thrudef) { thru = 1; begin = 1; /* wrong place */ } }
void syminit(void) { setsymtab("0", tostring("0"), 0.0, NUM|STR|CON|FLD, symtab); /* this one is used for if(x)... tests: */ setsymtab("$zero&null", tostring(""), 0.0, NUM|STR|CON|FLD, symtab); recloc = setsymtab("$record", record, 0.0, STR|FLD, symtab); dprintf("recloc %lo lookup %lo\n", (long)recloc, (long)lookup("$record", symtab, 0)); FS = &setsymtab("FS", tostring(" "), 0.0, STR|FLD, symtab)->sval; RS = &setsymtab("RS", tostring("\n"), 0.0, STR|FLD, symtab)->sval; OFS = &setsymtab("OFS", tostring(" "), 0.0, STR|FLD, symtab)->sval; ORS = &setsymtab("ORS", tostring("\n"), 0.0, STR|FLD, symtab)->sval; OFMT = &setsymtab("OFMT", tostring("%.6g"), 0.0, STR|FLD, symtab)->sval; FILENAME = &setsymtab("FILENAME", EMPTY, 0.0, STR|FLD, symtab)->sval; nfloc = setsymtab("NF", EMPTY, 0.0, NUM, symtab); NF = &nfloc->fval; nrloc = setsymtab("NR", EMPTY, 0.0, NUM, symtab); NR = &nrloc->fval; }
void frameside(int type, Attr *desc) /* create and remember sides */ { int n; char buf[100]; nsides++; switch (type) { case 0: /* no side specified; kludge up all */ frameside(TOP, desc); frameside(BOT, desc); frameside(LEFT, desc); frameside(RIGHT, desc); return; case TOP: n = 0; break; case BOT: n = 1; break; case LEFT: n = 2; break; case RIGHT: n = 3; break; } sprintf(buf, "%s %s", sides[n], desc_str(desc)); newsides[n] = tostring(buf); }