本文整理汇总了C++中setname函数的典型用法代码示例。如果您正苦于以下问题:C++ setname函数的具体用法?C++ setname怎么用?C++ setname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: START_TEST
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");
}
示例2: pexerr
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);
}
示例3: setname
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]);
}
示例4: MCValueRetain
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;
}
示例5: setpfad
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);
}
示例6: setname
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;
}
示例7: execute
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");
}
示例8: udvar
void
udvar(Char *name)
{
setname(vis_str(name));
stderror(ERR_NAME | ERR_UNDVAR);
/* NOTREACHED */
}
示例9: handleone
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);
}
示例10: change_nickname
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);
}
示例11: START_TEST
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");
}
示例12: EchoTC
/*
* 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);
}
示例13: ipush
static void
ipush(Istack *is)
{
if(istack == nil)
ibottom = is;
else
is->next = istack;
istack = is;
setname();
}
示例14: cmd_nick
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");
}
}
示例15: iqueue
static void
iqueue(Istack *is)
{
if(ibottom == nil){
istack = is;
setname();
}else
ibottom->next = is;
ibottom = is;
}