本文整理汇总了C++中sk_write函数的典型用法代码示例。如果您正苦于以下问题:C++ sk_write函数的具体用法?C++ sk_write怎么用?C++ sk_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sk_write函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: proxy_http_negotiate
int proxy_http_negotiate (ProxySocket *p, int change)
{
if (p->state == PROXY_STATE_NEW) {
/* we are just beginning the proxy negotiate process,
* so we'll send off the initial bits of the request.
* for this proxy method, it's just a simple HTTP
* request
*/
char *buf, dest[512];
char *username, *password;
sk_getaddr(p->remote_addr, dest, lenof(dest));
buf = dupprintf("CONNECT %s:%i HTTP/1.1\r\nHost: %s:%i\r\n",
dest, p->remote_port, dest, p->remote_port);
sk_write(p->sub_socket, buf, strlen(buf));
sfree(buf);
username = conf_get_str(p->conf, CONF_proxy_username);
password = conf_get_str(p->conf, CONF_proxy_password);
if (username[0] || password[0]) {
char *buf, *buf2;
int i, j, len;
buf = dupprintf("%s:%s", username, password);
len = strlen(buf);
buf2 = snewn(len * 4 / 3 + 100, char);
sprintf(buf2, "Proxy-Authorization: Basic ");
for (i = 0, j = strlen(buf2); i < len; i += 3, j += 4)
base64_encode_atom((unsigned char *)(buf+i),
(len-i > 3 ? 3 : len-i), buf2+j);
strcpy(buf2+j, "\r\n");
sk_write(p->sub_socket, buf2, strlen(buf2));
sfree(buf);
sfree(buf2);
}
开发者ID:Riatre,项目名称:PuTTY,代码行数:35,代码来源:proxy.c
示例2: adb_receive
static int adb_receive(Plug plug, int urgent, char *data, int len)
{
Adb adb = (Adb) plug;
if (adb->state == STATE_SENT_HELLO) {
if (data[0]=='O') { // OKAY
sk_write(adb->s,"0006shell:",10);
adb->state = STATE_ASKED_FOR_SHELL; // wait for shell start response
} else {
if (data[0]=='F') {
handle_fail(adb, data, len);
} else {
connection_fatal(adb->frontend, "Bad response after initial send");
}
return 0;
}
} else if (adb->state == STATE_ASKED_FOR_SHELL) {
if (data[0]=='O') { //OKAY
adb->state = STATE_CONNECTED; // shell started, switch to terminal mode
} else {
if (data[0]=='F') {
handle_fail(adb, data, len);
} else {
connection_fatal(adb->frontend, "Bad response waiting for shell start");
}
return 0;
}
} else if (adb->state == STATE_WAITING_FOR_ERROR_MESSAGE) {
do_fatal(adb, data, len);
} else {
c_write(adb, data, len);
}
return 1;
}
开发者ID:Alex131089,项目名称:PuTTYTray,代码行数:33,代码来源:adb.c
示例3: rlogin_send
/*
* Called to send data down the rlogin connection.
*/
static int rlogin_send(void *handle, char *buf, int len)
{
Rlogin rlogin = (Rlogin) handle;
if (rlogin->s == NULL)
return 0;
if (rlogin->prompt) {
/*
* We're still prompting for a username, and aren't talking
* directly to the network connection yet.
*/
int ret = get_userpass_input(rlogin->prompt,
(unsigned char *)buf, len);
if (ret >= 0) {
rlogin_startup(rlogin, rlogin->prompt->prompts[0]->result);
/* that nulls out rlogin->prompt, so then we'll start sending
* data down the wire in the obvious way */
}
} else {
rlogin->bufsize = sk_write(rlogin->s, buf, len);
}
return rlogin->bufsize;
}
开发者ID:4myPAL,项目名称:PuTTYTray,代码行数:28,代码来源:rlogin.c
示例4: main
int main(int argc, char *argv[])
{
if (argc < 2) {
usage();
} else {
/* Version command */
if (argv[1][0] == 'v') {
printf("%s\n", programVersion);
return 1;
}
if (argc > 2) {
/* Cmd Read / Write / version */
switch (argv[2][0]) {
case 'r':
case 'R':
sk_read(argc, argv);
break;
case 'w':
case 'W':
sk_write(argc, argv);
break;
}
}
}
return 1;
}
开发者ID:Meticulus,项目名称:vendor_st-ericsson_u8500,代码行数:31,代码来源:sk-i2c.c
示例5: proxy_socks5_selectchap
int proxy_socks5_selectchap(Proxy_Socket p)
{
if (p->cfg.proxy_username[0] || p->cfg.proxy_password[0]) {
char chapbuf[514];
int ulen;
chapbuf[0] = '\x01'; /* Version */
chapbuf[1] = '\x02'; /* Number of attributes sent */
chapbuf[2] = '\x11'; /* First attribute - algorithms list */
chapbuf[3] = '\x01'; /* Only one CHAP algorithm */
chapbuf[4] = '\x85'; /* ...and it's HMAC-MD5, the core one */
chapbuf[5] = '\x02'; /* Second attribute - username */
ulen = strlen(p->cfg.proxy_username);
if (ulen > 255) ulen = 255; if (ulen < 1) ulen = 1;
chapbuf[6] = ulen;
memcpy(chapbuf+7, p->cfg.proxy_username, ulen);
sk_write(p->sub_socket, chapbuf, ulen + 7);
p->chap_num_attributes = 0;
p->chap_num_attributes_processed = 0;
p->chap_current_attribute = -1;
p->chap_current_datalen = 0;
p->state = 8;
} else
plug_closing(p->plug, "Proxy error: Server chose "
"CHAP authentication but we didn't offer it!",
PROXY_ERROR_GENERAL, 0);
return 1;
}
开发者ID:7digital,项目名称:putty,代码行数:31,代码来源:cproxy.c
示例6: process_subneg
static void process_subneg(Telnet telnet)
{
unsigned char *b, *p, *q;
int var, value, n, bsize;
char *e, *eval, *ekey, *user;
switch (telnet->sb_opt) {
case TELOPT_TSPEED:
if (telnet->sb_len == 1 && telnet->sb_buf[0] == TELQUAL_SEND) {
char *logbuf;
char *termspeed = conf_get_str(telnet->conf, CONF_termspeed);
b = snewn(20 + strlen(termspeed), unsigned char);
b[0] = IAC;
b[1] = SB;
b[2] = TELOPT_TSPEED;
b[3] = TELQUAL_IS;
strcpy((char *)(b + 4), termspeed);
n = 4 + strlen(termspeed);
b[n] = IAC;
b[n + 1] = SE;
telnet->bufsize = sk_write(telnet->s, (char *)b, n + 2);
logevent(telnet->frontend, "server:\tSB TSPEED SEND");
logbuf = dupprintf("client:\tSB TSPEED IS %s", termspeed);
logevent(telnet->frontend, logbuf);
sfree(logbuf);
sfree(b);
} else
开发者ID:carloszamora,项目名称:ch4zilla,代码行数:27,代码来源:TELNET.C
示例7: raw_send
/*
* Called to send data down the raw connection.
*/
static int raw_send(char *buf, int len)
{
if (s == NULL)
return 0;
raw_bufsize = sk_write(s, buf, len);
return raw_bufsize;
}
开发者ID:rdebath,项目名称:sgt,代码行数:12,代码来源:raw.c
示例8: sk_proxy_write
static int sk_proxy_write(Socket s, const char *data, int len) {
Proxy_Socket ps = (Proxy_Socket) s;
if (ps->state != PROXY_STATE_ACTIVE) {
bufchain_add(&ps->pending_output_data, data, len);
return bufchain_size(&ps->pending_output_data);
}
return sk_write(ps->sub_socket, data, len);
}
开发者ID:zhangbo7364,项目名称:terminal,代码行数:9,代码来源:proxy.c
示例9: sk_proxy_write
static int sk_proxy_write (Socket s, const void *data, int len)
{
ProxySocket *ps = FROMFIELD(s, ProxySocket, sockvt);
if (ps->state != PROXY_STATE_ACTIVE) {
bufchain_add(&ps->pending_output_data, data, len);
return bufchain_size(&ps->pending_output_data);
}
return sk_write(ps->sub_socket, data, len);
}
开发者ID:Riatre,项目名称:PuTTY,代码行数:10,代码来源:proxy.c
示例10: send_opt
static void send_opt(Telnet telnet, int cmd, int option)
{
unsigned char b[3];
b[0] = IAC;
b[1] = cmd;
b[2] = option;
telnet->bufsize = sk_write(telnet->s, (char *)b, 3);
log_option(telnet, "client", cmd, option);
}
开发者ID:carloszamora,项目名称:ch4zilla,代码行数:10,代码来源:TELNET.C
示例11: sk_proxy_write
static size_t sk_proxy_write (Socket *s, const void *data, size_t len)
{
ProxySocket *ps = container_of(s, ProxySocket, sock);
if (ps->state != PROXY_STATE_ACTIVE) {
bufchain_add(&ps->pending_output_data, data, len);
return bufchain_size(&ps->pending_output_data);
}
return sk_write(ps->sub_socket, data, len);
}
开发者ID:TortoiseGit,项目名称:TortoiseGit,代码行数:10,代码来源:PROXY.C
示例12: adb_send
/*
* Called to send data down the adb connection.
*/
static int adb_send(void *handle, char *buf, int len)
{
Adb adb = (Adb) handle;
if (adb->s == NULL)
return 0;
adb->bufsize = sk_write(adb->s, buf, len);
return adb->bufsize;
}
开发者ID:Alex131089,项目名称:PuTTYTray,代码行数:14,代码来源:adb.c
示例13: rlogin_send
/*
* Called to send data down the rlogin connection.
*/
static int rlogin_send(void *handle, char *buf, int len)
{
Rlogin rlogin = (Rlogin) handle;
if (rlogin->s == NULL)
return 0;
rlogin->bufsize = sk_write(rlogin->s, buf, len);
return rlogin->bufsize;
}
开发者ID:BackupTheBerlios,项目名称:sftp4tc-svn,代码行数:14,代码来源:RLOGIN.C
示例14: proxy_activate
/*
* Call this when proxy negotiation is complete, so that this
* socket can begin working normally.
*/
void proxy_activate(Proxy_Socket p)
{
void *data;
int len;
long output_before, output_after;
p->state = PROXY_STATE_ACTIVE;
/* we want to ignore new receive events until we have sent
* all of our buffered receive data.
*/
sk_set_frozen(p->sub_socket, 1);
/* how many bytes of output have we buffered? */
output_before = bufchain_size(&p->pending_oob_output_data) +
bufchain_size(&p->pending_output_data);
/* and keep track of how many bytes do not get sent. */
output_after = 0;
/* send buffered OOB writes */
while (bufchain_size(&p->pending_oob_output_data) > 0) {
bufchain_prefix(&p->pending_oob_output_data, &data, &len);
output_after += sk_write_oob(p->sub_socket, data, len);
bufchain_consume(&p->pending_oob_output_data, len);
}
/* send buffered normal writes */
while (bufchain_size(&p->pending_output_data) > 0) {
bufchain_prefix(&p->pending_output_data, &data, &len);
output_after += sk_write(p->sub_socket, data, len);
bufchain_consume(&p->pending_output_data, len);
}
/* if we managed to send any data, let the higher levels know. */
if (output_after < output_before)
plug_sent(p->plug, output_after);
/* if we were asked to flush the output during
* the proxy negotiation process, do so now.
*/
if (p->pending_flush)
sk_flush(p->sub_socket);
/* if we have a pending EOF to send, send it */
if (p->pending_eof)
sk_write_eof(p->sub_socket);
/* if the backend wanted the socket unfrozen, try to unfreeze.
* our set_frozen handler will flush buffered receive data before
* unfreezing the actual underlying socket.
*/
if (!p->freeze)
sk_set_frozen((Socket)p, 0);
}
开发者ID:FauxFaux,项目名称:PuTTYTray,代码行数:58,代码来源:proxy.c
示例15: raw_send
/*
* Called to send data down the raw connection.
*/
static int raw_send(void *handle, char *buf, int len)
{
Raw raw = (Raw) handle;
if (raw->s == NULL)
return 0;
raw->bufsize = sk_write(raw->s, buf, len);
return raw->bufsize;
}
开发者ID:rmcardle,项目名称:PuTTYAxNG,代码行数:14,代码来源:RAW.C
示例16: pfd_confirm
void pfd_confirm(Socket s)
{
struct PFwdPrivate *pr;
if (s == NULL)
return;
pr = (struct PFwdPrivate *) sk_get_private_ptr(s);
pr->ready = 1;
sk_set_frozen(s, 0);
sk_write(s, NULL, 0);
}
开发者ID:rdebath,项目名称:sgt,代码行数:12,代码来源:portfwd.c
示例17: rlogin_size
/*
* Called to set the size of the window
*/
static void rlogin_size(void)
{
char b[12] = { '\xFF', '\xFF', 0x73, 0x73, 0, 0, 0, 0, 0, 0, 0, 0 };
if (s == NULL)
return;
b[6] = cols >> 8;
b[7] = cols & 0xFF;
b[4] = rows >> 8;
b[5] = rows & 0xFF;
rlogin_bufsize = sk_write(s, b, 12);
return;
}
开发者ID:rdebath,项目名称:sgt,代码行数:17,代码来源:rlogin.c
示例18: rlogin_startup
static void rlogin_startup(Rlogin rlogin, const char *ruser)
{
char z = 0;
char *p;
sk_write(rlogin->s, &z, 1);
sk_write(rlogin->s, rlogin->cfg.localusername,
strlen(rlogin->cfg.localusername));
sk_write(rlogin->s, &z, 1);
sk_write(rlogin->s, ruser,
strlen(ruser));
sk_write(rlogin->s, &z, 1);
sk_write(rlogin->s, rlogin->cfg.termtype,
strlen(rlogin->cfg.termtype));
sk_write(rlogin->s, "/", 1);
for (p = rlogin->cfg.termspeed; isdigit((unsigned char)*p); p++) continue;
sk_write(rlogin->s, rlogin->cfg.termspeed, p - rlogin->cfg.termspeed);
rlogin->bufsize = sk_write(rlogin->s, &z, 1);
rlogin->prompt = NULL;
}
开发者ID:kleopatra999,项目名称:PuTTY,代码行数:20,代码来源:rlogin.c
示例19: rlogin_startup
static void rlogin_startup(Rlogin rlogin, const char *ruser)
{
char z = 0;
char *p;
sk_write(rlogin->s, &z, 1);
p = conf_get_str(rlogin->conf, CONF_localusername);
sk_write(rlogin->s, p, strlen(p));
sk_write(rlogin->s, &z, 1);
sk_write(rlogin->s, ruser, strlen(ruser));
sk_write(rlogin->s, &z, 1);
p = conf_get_str(rlogin->conf, CONF_termtype);
sk_write(rlogin->s, p, strlen(p));
sk_write(rlogin->s, "/", 1);
p = conf_get_str(rlogin->conf, CONF_termspeed);
sk_write(rlogin->s, p, strspn(p, "0123456789"));
rlogin->bufsize = sk_write(rlogin->s, &z, 1);
rlogin->prompt = NULL;
}
开发者ID:4myPAL,项目名称:PuTTYTray,代码行数:20,代码来源:rlogin.c
示例20: rlogin_size
/*
* Called to set the size of the window
*/
static void rlogin_size(void *handle, int width, int height)
{
Rlogin rlogin = (Rlogin) handle;
char b[12] = { '\xFF', '\xFF', 0x73, 0x73, 0, 0, 0, 0, 0, 0, 0, 0 };
rlogin->term_width = width;
rlogin->term_height = height;
if (rlogin->s == NULL || !rlogin->cansize)
return;
b[6] = rlogin->term_width >> 8;
b[7] = rlogin->term_width & 0xFF;
b[4] = rlogin->term_height >> 8;
b[5] = rlogin->term_height & 0xFF;
rlogin->bufsize = sk_write(rlogin->s, b, 12);
return;
}
开发者ID:4myPAL,项目名称:PuTTYTray,代码行数:21,代码来源:rlogin.c
注:本文中的sk_write函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论