当前位置: 首页>>代码示例>>C++>>正文


C++ setname函数代码示例

本文整理汇总了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");
}
开发者ID:1h6,项目名称:ProjectTox-Core,代码行数:14,代码来源:messenger_test.c

示例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);
}
开发者ID:radixo,项目名称:openbsd-src,代码行数:16,代码来源:exec.c

示例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]);

}
开发者ID:waterlink,项目名称:tspp_project,代码行数:27,代码来源:human.cpp

示例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;
}
开发者ID:alilloyd,项目名称:livecode,代码行数:29,代码来源:eps.cpp

示例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);
}
开发者ID:nMerlin,项目名称:CP,代码行数:7,代码来源:plotter.cpp

示例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;
}
开发者ID:AsteroidOS,项目名称:android_system_core,代码行数:28,代码来源:CommandListener.cpp

示例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");
}
开发者ID:ghacnt,项目名称:ProjectTox-Core,代码行数:60,代码来源:chat.c

示例8: udvar

void
udvar(Char *name)
{
    setname(vis_str(name));
    stderror(ERR_NAME | ERR_UNDVAR);
    /* NOTREACHED */
}
开发者ID:IIJ-NetBSD,项目名称:netbsd-src,代码行数:7,代码来源:misc.c

示例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);
}
开发者ID:2014-class,项目名称:freerouter,代码行数:34,代码来源:sh.glob.c

示例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);
}
开发者ID:sodwalt,项目名称:ProjectTox-Core,代码行数:25,代码来源:nTox_win32.c

示例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");
}
开发者ID:13693100472,项目名称:toxcore,代码行数:47,代码来源:messenger_test.c

示例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);
}
开发者ID:Lance0312,项目名称:tcsh,代码行数:59,代码来源:nt.screen.c

示例13: ipush

static void
ipush(Istack *is)
{
	if(istack == nil)
		ibottom = is;
	else
		is->next = istack;
	istack = is;
	setname();
}
开发者ID:00001,项目名称:plan9port,代码行数:10,代码来源:input.c

示例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");
    }
}
开发者ID:notadecent,项目名称:toxic,代码行数:10,代码来源:prompt.c

示例15: iqueue

static void
iqueue(Istack *is)
{
	if(ibottom == nil){
		istack = is;
		setname();
	}else
		ibottom->next = is;
	ibottom = is;
}
开发者ID:00001,项目名称:plan9port,代码行数:10,代码来源:input.c


注:本文中的setname函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。