END_TEST START_TEST(test_setname) { char *good_name = "consensualCorn"; int good_length = strlen(good_name); int bad_length = REALLY_BIG_NUMBER; if(setname((uint8_t *)good_name, bad_length) != -1) ck_abort_msg("setname() did NOT error on %d as a length argument!\n", bad_length); if(setname((uint8_t *)good_name, good_length) != 0) ck_abort_msg("setname() did NOT return 0 on good arguments!\n"); }
static void pexerr(void) { /* Couldn't find the damn thing */ if (expath) { setname(vis_str(expath)); Vexpath = 0; xfree(expath); expath = 0; } else setname(""); if (exerr) stderror(ERR_NAME | ERR_STRING, exerr); stderror(ERR_NAME | ERR_COMMAND); }
void human::fromstring(string & data){ string S; stringcopier::copy(S, data); vector < string > V = stringcopier::split("\t", S); if (V.size() < 3){ errorstate::error = "human::fromstring - error 1: out of data"; errorstate::code = 1; return; } // name, first_name, fathers_name setname(V[0]); setfirst_name(V[1]); setfathers_name(V[2]); }
Boolean MCEPS::import(MCStringRef fname, IO_handle stream) { size = (uint4)MCS_fsize(stream); delete postscript; postscript = new char[size + 1]; if (IO_read(postscript, size, stream) != IO_NORMAL) return False; postscript[size] = '\0'; uindex_t t_sep; MCStringRef t_fname; if (MCStringLastIndexOfChar(fname, PATH_SEPARATOR, UINDEX_MAX, kMCCompareExact, t_sep)) /* UNCHECKED */ MCStringCopySubstring(fname, MCRangeMake(t_sep + 1, MCStringGetLength(fname) - (t_sep + 1)), t_fname); else t_fname = MCValueRetain(fname); MCNewAutoNameRef t_name; if (!MCNameCreateAndRelease(t_fname, &t_name)) return False; setname(*t_name); setextents(); rect.width = (uint2)(ex * xscale / xf); rect.height = (uint2)(ey * yscale / yf); if (flags & F_SHOW_BORDER) { rect.width += borderwidth << 1; rect.height += borderwidth << 1; } return True; }
int plotter::plot(std::function<double(double)> function, std::string pfad, std::string name, double schritte) { setpfad(pfad); setname(name); setschritte(schritte); return plot(function); }
int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli, int argc, char **argv) { setname(); if (!clientHasLogCredentials(cli)) { cli->sendMsg("Permission Denied"); return 0; } if (argc < 3) { cli->sendMsg("Missing Argument"); return 0; } int id = atoi(argv[1]); if ((id < LOG_ID_MIN) || (LOG_ID_MAX <= id)) { cli->sendMsg("Range Error"); return 0; } unsigned long size = atol(argv[2]); if (mBuf.setSize((log_id_t) id, size)) { cli->sendMsg("Range Error"); return 0; } cli->sendMsg("success"); return 0; }
void execute(ToxWindow *self, ChatContext *ctx, char *cmd) { if (!strcmp(cmd, "/clear") || !strcmp(cmd, "/c")) { wclear(self->window); wclear(ctx->history); } else if (!strcmp(cmd, "/help") || !strcmp(cmd, "/h")) print_help(ctx); else if (!strcmp(cmd, "/quit") || !strcmp(cmd, "/exit") || !strcmp(cmd, "/q")) { endwin(); exit(0); } else if (!strncmp(cmd, "/status ", strlen("/status "))) { char *msg; msg = strchr(cmd, ' '); if (msg == NULL) { wprintw(ctx->history, "Invalid syntax.\n"); return; } msg++; m_set_userstatus(USERSTATUS_KIND_RETAIN, (uint8_t*) msg, strlen(msg)+1); wprintw(ctx->history, "Status set to: %s\n", msg); } else if (!strncmp(cmd, "/nick ", strlen("/nick "))) { char *nick; nick = strchr(cmd, ' '); if (nick == NULL) { wprintw(ctx->history, "Invalid syntax.\n"); return; } nick++; setname((uint8_t*) nick, strlen(nick)+1); wprintw(ctx->history, "Nickname set to: %s\n", nick); } else if (!strcmp(cmd, "/myid")) { char id[32*2 + 1] = {0}; int i; for (i = 0; i < 32; i++) { char xx[3]; snprintf(xx, sizeof(xx), "%02x", self_public_key[i] & 0xff); strcat(id, xx); } wprintw(ctx->history, "Your ID: %s\n", id); } else if (strcmp(ctx->line, "/close") == 0) { active_window = 0; // Go to prompt screen int f_num = ctx->friendnum; delwin(ctx->linewin); del_window(self, f_num); } else wprintw(ctx->history, "Invalid command.\n"); }
void udvar(Char *name) { setname(vis_str(name)); stderror(ERR_NAME | ERR_UNDVAR); /* NOTREACHED */ }
int CommandListener::GetStatisticsCmd::runCommand(SocketClient *cli, int argc, char **argv) { setname(); uid_t uid = cli->getUid(); if (clientHasLogCredentials(cli)) { uid = AID_ROOT; } unsigned int logMask = -1; if (argc > 1) { logMask = 0; for (int i = 1; i < argc; ++i) { int id = atoi(argv[i]); if ((id < LOG_ID_MIN) || (LOG_ID_MAX <= id)) { cli->sendMsg("Range Error"); return 0; } logMask |= 1 << id; } } char *buf = NULL; mBuf.formatStatistics(&buf, uid, logMask); if (!buf) { cli->sendMsg("Failed"); } else { package_string(&buf); cli->sendMsg(buf); free(buf); } return 0; }
static Char * handleone(Char *str, Char **vl, int action) { size_t chars; Char **t, *p, *strp; switch (action) { case G_ERROR: setname(short2str(str)); blkfree(vl); stderror(ERR_NAME | ERR_AMBIG); break; case G_APPEND: chars = 0; for (t = vl; (p = *t++) != NULL; chars++) chars += Strlen(p); str = xmalloc(chars * sizeof(Char)); for (t = vl, strp = str; (p = *t++) != '\0'; chars++) { while (*p) *strp++ = *p++ & TRIM; *strp++ = ' '; } *--strp = '\0'; blkfree(vl); break; case G_IGNORE: str = Strsave(strip(*vl)); blkfree(vl); break; default: break; } return (str); }
void change_nickname() { uint8_t name[MAX_NAME_LENGTH]; int i = 0; size_t len = strlen(line); for (i = 3; i < len; i++) { if (line[i] == 0 || line[i] == '\n') break; name[i-3] = line[i]; } name[i-3] = 0; setname(name, i); char numstring[100]; sprintf(numstring, "\n[i] changed nick to %s\n\n", (char*)name); printf(numstring); FILE *name_file = NULL; name_file = fopen("namefile.txt", "w"); fprintf(name_file, "%s", (char*)name); fclose(name_file); }
int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli, int argc, char **argv) { setname(); if (!clientHasLogCredentials(cli)) { cli->sendMsg("Permission Denied"); return 0; } char *cp = NULL; for (int i = 1; i < argc; ++i) { char *p = cp; if (p) { cp = NULL; asprintf(&cp, "%s %s", p, argv[i]); free(p); } else { asprintf(&cp, "%s", argv[i]); } } int ret = mBuf.initPrune(cp); free(cp); if (ret) { cli->sendMsg("Invalid"); return 0; } cli->sendMsg("success"); return 0; }
END_TEST /* START_TEST(test_m_addfriend) { char *good_data = "test"; char *bad_data = ""; int good_len = strlen(good_data); int bad_len = strlen(bad_data); int really_bad_len = (MAX_CRYPTO_PACKET_SIZE - crypto_box_PUBLICKEYBYTES - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES + 100); */ /* TODO: Update this properly to latest master if(m_addfriend(m, (uint8_t *)friend_id, (uint8_t *)good_data, really_bad_len) != FAERR_TOOLONG) ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", really_bad_len); */ /* this will error if the original m_addfriend_norequest() failed */ /* if(m_addfriend(m, (uint8_t *)friend_id, (uint8_t *)good_data, good_len) != FAERR_ALREADYSENT) ck_abort_msg("m_addfriend did NOT catch adding a friend we already have.\n" "(this can be caused by the error of m_addfriend_norequest in" " the beginning of the suite)\n"); if(m_addfriend(m, (uint8_t *)good_id_b, (uint8_t *)bad_data, bad_len) != FAERR_NOMESSAGE) ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", bad_len); */ /* this should REALLY error */ /* * TODO: validate client_id in m_addfriend? if(m_addfriend((uint8_t *)bad_id, (uint8_t *)good_data, good_len) >= 0) ck_abort_msg("The following ID passed through " "m_addfriend without an error:\n'%s'\n", bad_id_str); } END_TEST */ START_TEST(test_setname) { char *good_name = "consensualCorn"; int good_length = strlen(good_name); int bad_length = REALLY_BIG_NUMBER; ck_assert_msg((setname(m, (uint8_t *)good_name, bad_length) == -1), "setname() did NOT error on %d as a length argument!\n", bad_length); ck_assert_msg((setname(m, (uint8_t *)good_name, good_length) == 0), "setname() did NOT return 0 on good arguments!\n"); }
/* * Print the termcap string out with variable substitution */ void EchoTC(Char **v) { Char **globbed; char cv[BUFSIZE];/*FIXBUF*/ int verbose = 0, silent = 0; static char *fmts = "%s\n", *fmtd = "%d\n"; int li,co; setname("echotc"); v = glob_all_or_error(v); globbed = v; cleanup_push(globbed, blk_cleanup); if (!v || !*v || *v[0] == '\0') goto end; if (v[0][0] == '-') { switch (v[0][1]) { case 'v': verbose = 1; break; case 's': silent = 1; break; default: stderror(ERR_NAME | ERR_TCUSAGE); break; } v++; } if (!*v || *v[0] == '\0') goto end; (void) StringCbCopy(cv,sizeof(cv), short2str(*v)); GetSize(&li,&co); if(!lstrcmp(cv,"rows") || !lstrcmp(cv,"lines") ) { xprintf(fmtd,T_Lines); goto end; } else if(!lstrcmp(cv,"cols") ) { xprintf(fmtd,T_ActualWindowSize); goto end; } else if(!lstrcmp(cv,"buffer") ) { xprintf(fmtd,T_Cols); goto end; } else stderror(ERR_SYSTEM, "EchoTC","Sorry, this function is not supported"); end: cleanup_until(globbed); }
int plotter::plot(std::function<double(double)> function, std::string pfad, std::string name, double schritte, double start, double stop, std::string xlabel, std::string ylabel) { setpfad(pfad); setname(name); setschritte(schritte); setxrange(start,stop); setxlabel(xlabel); setylabel(ylabel); return plot(function); }
static void ipush(Istack *is) { if(istack == nil) ibottom = is; else is->next = istack; istack = is; setname(); }
void cmd_nick(ToxWindow *self, Messenger *m, char **args) { char *nick = args[1]; setname(m, (uint8_t *) nick, strlen(nick) + 1); wprintw(self->window, "Nickname set to: %s\n", nick); if (store_data(m, DATA_FILE)) { wprintw(self->window, "\nCould not store Messenger data\n"); } }
static void iqueue(Istack *is) { if(ibottom == nil){ istack = is; setname(); }else ibottom->next = is; ibottom = is; }
int CommandListener::ReinitCmd::runCommand(SocketClient *cli, int /*argc*/, char ** /*argv*/) { setname(); reinit_signal_handler(SIGHUP); cli->sendMsg("success"); return 0; }
int MealModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 3) qt_static_metacall(this, _c, _id, _a); _id -= 3; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = type(); break; case 1: *reinterpret_cast< QString*>(_v) = name(); break; case 2: *reinterpret_cast< QString*>(_v) = price(); break; } _id -= 3; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: settype(*reinterpret_cast< QString*>(_v)); break; case 1: setname(*reinterpret_cast< QString*>(_v)); break; case 2: setprice(*reinterpret_cast< QString*>(_v)); break; } _id -= 3; } else if (_c == QMetaObject::ResetProperty) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 3; } #endif // QT_NO_PROPERTIES return _id; }
/* newclosure - allocate and initialize a new closure */ LVAL newclosure(LVAL name, LVAL type, LVAL env, LVAL fenv) { LVAL val; val = newvector(CLOSIZE); val->n_type = CLOSURE; setname(val,name); settype(val,type); setenv(val,env); setfenv(val,fenv); return (val); }
/* Set our nickname. * name must be a string of maximum MAX_NAME_LENGTH length. * length must be at least 1 byte. * length is the length of name with the NULL terminator. * * return 0 if success. * return -1 if failure. */ int tox_set_name(Tox *tox, const uint8_t *name, uint16_t length) { Messenger *m = tox; if (setname(m, name, length) == 0) { send_name_all_groups(m->group_chat_object); return 0; } else { return -1; } }
table::table() { m_xhost = m_config.at("lollipop.db.host"); m_xusername = m_config.at("lollipop.db.user"); m_xpassword = m_config.at("lollipop.db.password"); m_xdbname = m_config.at("lollipop.db.dbname"); m_xtablename = NULL; m_datafile = m_config.at("lollipop.db.datafile", NULL); // TODO: save data to file on errors m_sqlout = atoi(m_config.at("lollipop.db.logsql", "0")); m_debugmode = atoi(m_config.at("lollipop.db.debug", "0")); setname("DEFAULT_TABLE_NAME"); }
static Messenger * init_tox() { /* Init core */ Messenger *m = initMessenger(); /* Callbacks */ m_callback_friendrequest(m, on_request, NULL); m_callback_friendmessage(m, on_message, NULL); m_callback_namechange(m, on_nickchange, NULL); m_callback_statusmessage(m, on_statuschange, NULL); m_callback_action(m, on_action, NULL); #ifdef __linux__ setname(m, (uint8_t*) "Cool guy", sizeof("Cool guy")); #elif WIN32 setname(m, (uint8_t*) "I should install GNU/Linux", sizeof("I should install GNU/Linux")); #else setname(m, (uint8_t*) "Hipster", sizeof("Hipster")); #endif return m; }
Char * globone(Char *str, int action) { Char *v[2], **vl, **vo; int gflg, noglob; noglob = adrof(STRnoglob) != 0; v[0] = str; v[1] = 0; gflg = tglob(v); if (gflg == G_NONE) return (strip(Strsave(str))); if (gflg & G_CSH) { /* * Expand back-quote, tilde and brace */ vo = globexpand(v, noglob); if (noglob || (gflg & G_GLOB) == 0) { vl = vo; goto result; } cleanup_push(vo, blk_cleanup); } else if (noglob || (gflg & G_GLOB) == 0) return (strip(Strsave(str))); else vo = v; vl = libglob(vo); if (gflg & G_CSH) { if (vl != vo) cleanup_until(vo); else cleanup_ignore(vo); } if (vl == NULL) { setname(short2str(str)); stderror(ERR_NAME | ERR_NOMATCH); } result: if (vl && vl[0] == NULL) { xfree(vl); return (Strsave(STRNULL)); } if (vl && vl[1]) return (handleone(str, vl, action)); else { str = strip(*vl); xfree(vl); return (str); } }
Face* nextface(void) { int i; Face *f; Plumbmsg *m; char *t, *senderp, *showmailp, *digestp; ulong xtime; f = emalloc(sizeof(Face)); for(;;){ if(seefd >= 0){ m = plumbrecv(seefd); if(m == nil) killall("error on seemail plumb port"); t = value(m->attr, "mailtype", ""); if(strcmp(t, "delete") == 0) delete(m->data, value(m->attr, "digest", nil)); else if(strcmp(t, "new") != 0) fprint(2, "faces: unknown plumb message type %s\n", t); else for(i=0; i<nmaildirs; i++) if(strncmp(m->data, maildirs[i], strlen(maildirs[i])) == 0) goto Found; plumbfree(m); continue; Found: xtime = parsedate(value(m->attr, "date", date)); digestp = value(m->attr, "digest", nil); if(alreadyseen(digestp)){ /* duplicate upas/fs can send duplicate messages */ plumbfree(m); continue; } senderp = estrdup(value(m->attr, "sender", "???")); showmailp = estrdup(m->data); if(digestp) digestp = estrdup(digestp); plumbfree(m); }else{ if(logrecv(&senderp, &xtime) <= 0) killall("error reading log file"); showmailp = estrdup(""); digestp = nil; } setname(f, senderp); f->time = xtime; f->tm = *localtime(xtime); f->str[Sshow] = showmailp; f->str[Sdigest] = digestp; return f; } }
Face* dirface(char *dir, char *num) { Face *f; char *from, *date; char buf[1024], pwd[1024], *info, *p, *digest; int n, fd; ulong len; /* * loadmbox leaves us in maildir, so we needn't * walk /mail/fs/mbox for each face; this makes startup * a fair bit quicker. */ if(getwd(pwd, sizeof pwd) != nil && strcmp(pwd, dir) == 0) sprint(buf, "%s/info", num); else sprint(buf, "%s/%s/info", dir, num); len = dirlen(buf); if(len <= 0) return nil; fd = open(buf, OREAD); if(fd < 0) return nil; info = emalloc(len+1); n = readn(fd, info, len); close(fd); if(n < 0){ free(info); return nil; } info[n] = '\0'; f = emalloc(sizeof(Face)); from = iline(info, &p); /* from */ iline(p, &p); /* to */ iline(p, &p); /* cc */ iline(p, &p); /* replyto */ date = iline(p, &p); /* date */ setname(f, estrdup(from)); f->time = parsedate(date); f->tm = *localtime(f->time); sprint(buf, "%s/%s", dir, num); f->str[Sshow] = estrdup(buf); iline(p, &p); /* subject */ iline(p, &p); /* mime content type */ iline(p, &p); /* mime disposition */ iline(p, &p); /* filename */ digest = iline(p, &p); /* digest */ f->str[Sdigest] = estrdup(digest); free(info); return f; }
static Messenger *init_tox() { /* Init core */ Messenger *m = initMessenger(); /* Callbacks */ m_callback_friendrequest(m, on_request, NULL); m_callback_friendmessage(m, on_message, NULL); m_callback_namechange(m, on_nickchange, NULL); m_callback_statusmessage(m, on_statuschange, NULL); m_callback_action(m, on_action, NULL); #ifdef __linux__ setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy")); #elif defined(WIN32) setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux")); #elif defined(__APPLE__) setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters #else setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4")); #endif return m; }
/* * Swaps a slot with another */ void Bank::swapslot(unsigned int n1, unsigned int n2) { if((n1 == n2) || (locked())) return; if(emptyslot(n1) && (emptyslot(n2))) return; if(emptyslot(n1)) { //change n1 to n2 in order to make int tmp = n2; n2 = n1; n1 = tmp; } if(emptyslot(n2)) { //this is just a movement from slot1 to slot2 setname(n1, getname(n1), n2); ins[n2] = ins[n1]; ins[n1].used = false; ins[n1].name[0] = '\0'; ins[n1].filename = NULL; ins[n1].info.PADsynth_used = 0; } else { //if both slots are used if(strcmp(ins[n1].name, ins[n2].name) == 0) //change the name of the second instrument if the name are equal strncat(ins[n2].name, "2", PART_MAX_NAME_LEN); ; setname(n1, getname(n1), n2); setname(n2, getname(n2), n1); ins_t tmp; tmp.used = true; strcpy(tmp.name, ins[n2].name); char *tmpfilename = ins[n2].filename; bool padsynth_used = ins[n2].info.PADsynth_used; ins[n2] = ins[n1]; strcpy(ins[n1].name, tmp.name); ins[n1].filename = tmpfilename; ins[n1].info.PADsynth_used = padsynth_used; } }
int CommandListener::GetPruneListCmd::runCommand(SocketClient *cli, int /*argc*/, char ** /*argv*/) { setname(); char *buf = NULL; mBuf.formatPrune(&buf); if (!buf) { cli->sendMsg("Failed"); } else { package_string(&buf); cli->sendMsg(buf); free(buf); } return 0; }