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


C++ printsub函数代码示例

本文整理汇总了C++中printsub函数的典型用法代码示例。如果您正苦于以下问题:C++ printsub函数的具体用法?C++ printsub怎么用?C++ printsub使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了printsub函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: suboption

static void suboption(struct connectdata *conn)
{
    struct curl_slist *v;
    unsigned char temp[2048];
    int len;
    int tmplen;
    char varname[128];
    char varval[128];
    struct SessionHandle *data = conn->data;
    struct TELNET *tn = (struct TELNET *)conn->proto.telnet;

    printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn)+2);
    switch (CURL_SB_GET(tn))
    {
    case CURL_TELOPT_TTYPE:
        len = strlen(tn->subopt_ttype) + 4 + 2;
        snprintf((char *)temp, sizeof(temp),
                 "%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE,
                 CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC, CURL_SE);
        (void)swrite(conn->sock[FIRSTSOCKET], temp, len);
        printsub(data, '>', &temp[2], len-2);
        break;
    case CURL_TELOPT_XDISPLOC:
        len = strlen(tn->subopt_xdisploc) + 4 + 2;
        snprintf((char *)temp, sizeof(temp),
                 "%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC,
                 CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC, CURL_SE);
        (void)swrite(conn->sock[FIRSTSOCKET], temp, len);
        printsub(data, '>', &temp[2], len-2);
        break;
    case CURL_TELOPT_NEW_ENVIRON:
        snprintf((char *)temp, sizeof(temp),
                 "%c%c%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON,
                 CURL_TELQUAL_IS);
        len = 4;

        for(v = tn->telnet_vars; v; v = v->next)
        {
            tmplen = (strlen(v->data) + 1);
            /* Add the variable only if it fits */
            if(len + tmplen < (int)sizeof(temp)-6)
            {
                sscanf(v->data, "%127[^,],%s", varname, varval);
                snprintf((char *)&temp[len], sizeof(temp) - len,
                         "%c%s%c%s", CURL_NEW_ENV_VAR, varname,
                         CURL_NEW_ENV_VALUE, varval);
                len += tmplen;
            }
        }
        snprintf((char *)&temp[len], sizeof(temp) - len,
                 "%c%c", CURL_IAC, CURL_SE);
        len += 2;
        (void)swrite(conn->sock[FIRSTSOCKET], temp, len);
        printsub(data, '>', &temp[2], len-2);
        break;
    }
    return;
}
开发者ID:revelator,项目名称:Revelator-Doom3,代码行数:58,代码来源:telnet.c

示例2: slc_import

void
slc_import(int def)
{
    if (NETROOM() > (int)sizeof(slc_import_val)) {
	if (def) {
	    ring_supply_data(&netoring, slc_import_def, sizeof(slc_import_def));
	    printsub('>', &slc_import_def[2], sizeof(slc_import_def)-2);
	} else {
	    ring_supply_data(&netoring, slc_import_val, sizeof(slc_import_val));
	    printsub('>', &slc_import_val[2], sizeof(slc_import_val)-2);
	}
    }
/*@*/ else printf("slc_import: not enough room\n");
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:14,代码来源:telnet.c

示例3: auth_request

/*
 * This routine is called by the server to start authentication
 * negotiation.
 */
void
auth_request(void)
{
	static unsigned char str_request[64] = { IAC, SB,
						 TELOPT_AUTHENTICATION,
						 TELQUAL_SEND, };
	Authenticator *ap = authenticators;
	unsigned char *e = str_request + 4;

	if (!authenticating) {
		authenticating = 1;
		while (ap->type) {
			if (i_support & ~i_wont_support & typemask(ap->type)) {
				if (auth_debug_mode) {
					printf(">>>%s: Sending type %d %d\r\n",
						Name, ap->type, ap->way);
				}
				*e++ = ap->type;
				*e++ = ap->way;
			}
			++ap;
		}
		*e++ = IAC;
		*e++ = SE;
		net_write(str_request, e - str_request);
		printsub('>', &str_request[2], e - str_request - 2);
	}
}
开发者ID:seco,项目名称:freebsd-pi,代码行数:32,代码来源:auth.c

示例4: Data

static int
Data(Authenticator *ap, int type, void *d, int c)
{
    unsigned char *p = str_data + 4;
    unsigned char *cd = (unsigned char *)d;

    if (c == -1)
	c = strlen(cd);

    if (auth_debug_mode) {
	printf("%s:%d: [%d] (%d)",
	       str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
	       str_data[3],
	       type, c);
	printd(d, c);
	printf("\r\n");
    }
    *p++ = ap->type;
    *p++ = ap->way;
    *p++ = type;
    while (c-- > 0) {
	if ((*p++ = *cd++) == IAC)
	    *p++ = IAC;
    }
    *p++ = IAC;
    *p++ = SE;
    if (str_data[3] == TELQUAL_IS)
	printsub('>', &str_data[2], p - &str_data[2]);
    return(net_write(str_data, p - str_data));
}
开发者ID:aunali1,项目名称:exopc,代码行数:30,代码来源:kerberos5.c

示例5: get_status

int
get_status()
{
    unsigned char tmp[16];
    unsigned char *cp;

    if (my_want_state_is_dont(TELOPT_STATUS)) {
	printf("Remote side does not support STATUS option\n");
	return 0;
    }
    cp = tmp;

    *cp++ = IAC;
    *cp++ = SB;
    *cp++ = TELOPT_STATUS;
    *cp++ = TELQUAL_SEND;
    *cp++ = IAC;
    *cp++ = SE;
    if (NETROOM() >= cp - tmp) {
	ring_supply_data(&netoring, tmp, cp-tmp);
	printsub('>', tmp+2, cp - tmp - 2);
    }
    ++want_status_response;
    return 1;
}
开发者ID:SimonWilkinson,项目名称:heimdal,代码行数:25,代码来源:telnet.c

示例6: sendnaws

void
sendnaws()
{
    long rows, cols;
    unsigned char tmp[16];
    unsigned char *cp;

    if (my_state_is_wont(TELOPT_NAWS))
	return;

#undef PUTSHORT
#define	PUTSHORT(cp, x) { if ((*cp++ = ((x)>>8)&0xff) == IAC) *cp++ = IAC; \
			    if ((*cp++ = ((x))&0xff) == IAC) *cp++ = IAC; }

    if (TerminalWindowSize(&rows, &cols) == 0) {	/* Failed */
	return;
    }

    cp = tmp;

    *cp++ = IAC;
    *cp++ = SB;
    *cp++ = TELOPT_NAWS;
    PUTSHORT(cp, cols);
    PUTSHORT(cp, rows);
    *cp++ = IAC;
    *cp++ = SE;
    if (NETROOM() >= cp - tmp) {
	ring_supply_data(&netoring, tmp, cp-tmp);
	printsub('>', tmp+2, cp - tmp - 2);
    }
}
开发者ID:SimonWilkinson,项目名称:heimdal,代码行数:32,代码来源:telnet.c

示例7: getterminaltype

static int
getterminaltype (void)
{
  int retval = -1;

  settimer(baseline);

  send_do(TELOPT_TTYPE, 1);
  send_do(TELOPT_TSPEED, 1);
  send_do(TELOPT_XDISPLOC, 1);
  send_do(TELOPT_ENVIRON, 1);
  while (his_will_wont_is_changing(TELOPT_TTYPE) ||
	 his_will_wont_is_changing(TELOPT_TSPEED) ||
	 his_will_wont_is_changing(TELOPT_XDISPLOC) ||
	 his_will_wont_is_changing(TELOPT_ENVIRON)) {
    ttloop();
  }

  if (his_state_is_will(TELOPT_TSPEED)) {
    static unsigned char sb[] =
    { IAC, SB, TELOPT_TSPEED, TELQUAL_SEND, IAC, SE };

    memmove((void *)nfrontp, (void *)sb, sizeof sb);
    nfrontp += sizeof sb;
    DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
  }
开发者ID:a5216652166,项目名称:rcp100,代码行数:26,代码来源:telnetd.c

示例8: getterminaltype

int
getterminaltype(char *name, size_t name_sz)
{
    int retval = -1;

    settimer(baseline);
#ifdef AUTHENTICATION
    /*
     * Handle the Authentication option before we do anything else.
     */
    send_do(TELOPT_AUTHENTICATION, 1);
    while (his_will_wont_is_changing(TELOPT_AUTHENTICATION))
	ttloop();
    if (his_state_is_will(TELOPT_AUTHENTICATION)) {
	retval = auth_wait(name, name_sz);
    }
#endif

#ifdef ENCRYPTION
    send_will(TELOPT_ENCRYPT, 1);
    send_do(TELOPT_ENCRYPT, 1);	/* [email protected] */
#endif
    /* DayDream wants binary transmission mode */
    send_will(TELOPT_BINARY, 1);
    send_do(TELOPT_BINARY, 1);
    send_do(TELOPT_TTYPE, 1);
    send_do(TELOPT_TSPEED, 1);
    send_do(TELOPT_XDISPLOC, 1);
    send_do(TELOPT_NEW_ENVIRON, 1);
    send_do(TELOPT_OLD_ENVIRON, 1);
    while (
#ifdef ENCRYPTION
	   his_do_dont_is_changing(TELOPT_ENCRYPT) ||
#endif
	   his_do_dont_is_changing(TELOPT_BINARY) ||
	   his_will_wont_is_changing(TELOPT_TTYPE) ||
	   his_will_wont_is_changing(TELOPT_TSPEED) ||
	   his_will_wont_is_changing(TELOPT_XDISPLOC) ||
	   his_will_wont_is_changing(TELOPT_NEW_ENVIRON) ||
	   his_will_wont_is_changing(TELOPT_OLD_ENVIRON)) {
	ttloop();
    }
#ifdef ENCRYPTION
    /*
     * Wait for the negotiation of what type of encryption we can
     * send with.  If autoencrypt is not set, this will just return.
     */
    if (his_state_is_will(TELOPT_ENCRYPT)) {
	encrypt_wait();
    }
#endif
    if (his_state_is_will(TELOPT_BINARY)) {
	static unsigned char sb[] =
	{ IAC, SB, TELOPT_BINARY, TELQUAL_SEND, IAC, SE };

	telnet_net_write (sb, sizeof sb);
	DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
    }
开发者ID:hlyytine,项目名称:daydream,代码行数:58,代码来源:telnetd.c

示例9: fb64_start

static int
fb64_start(struct fb *fbp, int dir, int server __unused)
{
	size_t x;
	unsigned char *p;
	int state;

	switch (dir) {
	case DIR_DECRYPT:
		/*
		 * This is simply a request to have the other side
		 * start output (our input).  He will negotiate an
		 * IV so we need not look for it.
		 */
		state = fbp->state[dir-1];
		if (state == FAILED)
			state = IN_PROGRESS;
		break;

	case DIR_ENCRYPT:
		state = fbp->state[dir-1];
		if (state == FAILED)
			state = IN_PROGRESS;
		else if ((state & NO_SEND_IV) == 0)
			break;

		if (!VALIDKEY(fbp->krbdes_key)) {
			fbp->need_start = 1;
			break;
		}
		state &= ~NO_SEND_IV;
		state |= NO_RECV_IV;
		if (encrypt_debug_mode)
			printf("Creating new feed\r\n");
		/*
		 * Create a random feed and send it over.
		 */
		des_random_key((Block *)fbp->temp_feed);
		des_ecb_encrypt((Block *)fbp->temp_feed, (Block *)fbp->temp_feed,
				fbp->krbdes_sched, 1);
		p = fbp->fb_feed + 3;
		*p++ = ENCRYPT_IS;
		p++;
		*p++ = FB64_IV;
		for (x = 0; x < sizeof(Block); ++x) {
			if ((*p++ = fbp->temp_feed[x]) == IAC)
				*p++ = IAC;
		}
		*p++ = IAC;
		*p++ = SE;
		printsub('>', &fbp->fb_feed[2], p - &fbp->fb_feed[2]);
		net_write(fbp->fb_feed, p - fbp->fb_feed);
		break;
	default:
		return(FAILED);
	}
	return(fbp->state[dir-1] = state);
}
开发者ID:2014-class,项目名称:freerouter,代码行数:58,代码来源:enc_des.c

示例10: sendsuboption

static void sendsuboption(struct connectdata *conn, int option)
{
  ssize_t bytes_written;
  int err;
  unsigned short x, y;
  unsigned char*uc1, *uc2;

  struct SessionHandle *data = conn->data;
  struct TELNET *tn = (struct TELNET *)data->req.protop;

  switch (option) {
  case CURL_TELOPT_NAWS:
    /* We prepare data to be sent */
    CURL_SB_CLEAR(tn);
    CURL_SB_ACCUM(tn, CURL_IAC);
    CURL_SB_ACCUM(tn, CURL_SB);
    CURL_SB_ACCUM(tn, CURL_TELOPT_NAWS);
    /* We must deal either with litte or big endien processors */
    /* Window size must be sent according to the 'network order' */
    x=htons(tn->subopt_wsx);
    y=htons(tn->subopt_wsy);
    uc1 = (unsigned char*)&x;
    uc2 = (unsigned char*)&y;
    CURL_SB_ACCUM(tn, uc1[0]);
    CURL_SB_ACCUM(tn, uc1[1]);
    CURL_SB_ACCUM(tn, uc2[0]);
    CURL_SB_ACCUM(tn, uc2[1]);

    CURL_SB_ACCUM(tn, CURL_IAC);
    CURL_SB_ACCUM(tn, CURL_SE);
    CURL_SB_TERM(tn);
    /* data suboption is now ready */

    printsub(data, '>', (unsigned char *)tn->subbuffer+2,
             CURL_SB_LEN(tn)-2);

    /* we send the header of the suboption... */
    bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer, 3);
    if(bytes_written < 0) {
      err = SOCKERRNO;
      failf(data, "Sending data failed (%d)", err);
    }
    /* ... then the window size with the send_telnet_data() function
       to deal with 0xFF cases ... */
    send_telnet_data(conn, (char *)tn->subbuffer+3, 4);
    /* ... and the footer */
    bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer+7, 2);
    if(bytes_written < 0) {
      err = SOCKERRNO;
      failf(data, "Sending data failed (%d)", err);
    }
    break;
  }
}
开发者ID:AndyUI,项目名称:curl,代码行数:54,代码来源:telnet.c

示例11: encrypt_send_support

void
encrypt_send_support(void)
{
	if (str_suplen) {
		/*
		 * If the user has requested that decryption start
		 * immediatly, then send a "REQUEST START" before
		 * we negotiate the type.
		 */
		if (!Server && autodecrypt)
			encrypt_send_request_start();
		net_write(str_send, str_suplen);
		printsub('>', &str_send[2], str_suplen - 2);
		str_suplen = 0;
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:16,代码来源:encrypt.c

示例12: end_slc

/*
 * end_slc
 *
 * Finish up the slc negotiation.  If something to send, then send it.
 */
int
end_slc (register unsigned char **bufp)
{
  register int len;
  void netflush ();

  /*
   * If a change has occured, store the new terminal control
   * structures back to the terminal driver.
   */
  if (slcchange)
    {
      set_termbuf ();
    }

  /*
   * If the pty state has not yet been fully processed and there is a
   * deferred slc request from the client, then do not send any
   * sort of slc negotiation now.  We will respond to the client's
   * request very soon.
   */
  if (def_slcbuf && (terminit () == 0))
    {
      return (0);
    }

  if (slcptr > (slcbuf + 4))
    {
      if (bufp)
	{
	  *bufp = &slcbuf[4];
	  return (slcptr - slcbuf - 4);
	}
      else
	{
	  sprintf ((char *) slcptr, "%c%c", IAC, SE);
	  slcptr += 2;
	  len = slcptr - slcbuf;
	  net_output_datalen (slcbuf, len);
	  netflush ();		/* force it out immediately */
	  DEBUG (debug_options, 1, printsub ('>', slcbuf + 2, len - 2));
	}
    }
  return (0);

}				/* end of end_slc */
开发者ID:DanielMSchmidt,项目名称:it-sec,代码行数:51,代码来源:slc.c

示例13: slc_end_reply

void
slc_end_reply(void)
{
    int len;
    /* The end of negotiation command requires 2 bytes. */
    if (&slc_replyp[2] > slc_reply_eom)
	return;
    *slc_replyp++ = IAC;
    *slc_replyp++ = SE;
    len = slc_replyp - slc_reply;
    if (len <= 6)
	return;
    if (NETROOM() > len) {
	ring_supply_data(&netoring, slc_reply, slc_replyp - slc_reply);
	printsub('>', &slc_reply[2], slc_replyp - slc_reply - 2);
    }
/*@*/else printf("slc_end_reply: not enough room\n");
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:18,代码来源:telnet.c

示例14: tn3270_ttype

    int
tn3270_ttype(void)
{
    /*
     * Try to send a 3270 type terminal name.  Decide which one based
     * on the format of our screen, and (in the future) color
     * capaiblities.
     */
    InitTerminal();		/* Sets MaxNumberColumns, MaxNumberLines */
    if ((MaxNumberLines >= 24) && (MaxNumberColumns >= 80)) {
	Sent3270TerminalType = 1;
	if ((MaxNumberLines >= 27) && (MaxNumberColumns >= 132)) {
	    MaxNumberLines = 27;
	    MaxNumberColumns = 132;
	    sb_terminal[SBTERMMODEL] = '5';
	} else if (MaxNumberLines >= 43) {
	    MaxNumberLines = 43;
	    MaxNumberColumns = 80;
	    sb_terminal[SBTERMMODEL] = '4';
	} else if (MaxNumberLines >= 32) {
	    MaxNumberLines = 32;
	    MaxNumberColumns = 80;
	    sb_terminal[SBTERMMODEL] = '3';
	} else {
	    MaxNumberLines = 24;
	    MaxNumberColumns = 80;
	    sb_terminal[SBTERMMODEL] = '2';
	}
	NumberLines = 24;		/* before we start out... */
	NumberColumns = 80;
	ScreenSize = NumberLines*NumberColumns;
	if ((MaxNumberLines*MaxNumberColumns) > MAXSCREENSIZE) {
	    ExitString("Programming error:  MAXSCREENSIZE too small.\n",
								1);
	    /*NOTREACHED*/
	}
	printsub('>', sb_terminal+2, sizeof sb_terminal-2);
	ring_supply_data(&netoring, sb_terminal, sizeof sb_terminal);
	return 1;
    } else {
	return 0;
    }
}
开发者ID:a5216652166,项目名称:rcp100,代码行数:43,代码来源:tn3270.c

示例15: lm_mode

void
lm_mode(unsigned char *cmd, int len, int init)
{
	if (len != 1)
		return;
	if ((linemode&MODE_MASK&~MODE_ACK) == *cmd)
		return;
	if (*cmd&MODE_ACK)
		return;
	linemode = *cmd&(MODE_MASK&~MODE_ACK);
	str_lm_mode[4] = linemode;
	if (!init)
	    str_lm_mode[4] |= MODE_ACK;
	if (NETROOM() > (int)sizeof(str_lm_mode)) {
	    ring_supply_data(&netoring, str_lm_mode, sizeof(str_lm_mode));
	    printsub('>', &str_lm_mode[2], sizeof(str_lm_mode)-2);
	}
/*@*/	else printf("lm_mode: not enough room in buffer\n");
	setconnmode(0);	/* set changed mode */
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:20,代码来源:telnet.c


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