本文整理汇总了C++中show_msg函数的典型用法代码示例。如果您正苦于以下问题:C++ show_msg函数的具体用法?C++ show_msg怎么用?C++ show_msg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了show_msg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: g_ptr_array_sized_new
static void *correct_thread(void *data) {
correct_aux_t *d = (correct_aux_t*) data;
int i = 0;
bwa_seq_t *s = NULL, *query = NULL, *seqs = d->ht->seqs;
readarray *low_kmer_reads = d->low_kmer_reads;
alignarray *aligns = NULL;
aligns = g_ptr_array_sized_new(N_DEFAULT_ALIGNS);
for (i = d->start; i < d->end; i++) {
if (i % 10000 == 0)
show_msg(__func__,
"Thread %d correction progress: [%d,%d,%d]... \n", d->tid,
d->start, i, d->end);
s = g_ptr_array_index(low_kmer_reads, i);
if (is_repetitive_q(s)) {
s->status = USED;
continue;
}
// Only the fresh reads, or the reads tried once would be corrected.
if (s->status != FRESH)
continue;
query = new_seq(s, s->len - 8, 0);
pe_aln_query(s, s->seq, d->ht, MISMATCHES, s->len, 0, aligns);
pe_aln_query(s, s->rseq, d->ht, MISMATCHES, s->len, 1, aligns);
if (aligns->len >= 4)
correct_bases(seqs, s, aligns, d->tid);
s->status = TRIED;
reset_alg(aligns);
bwa_free_read_seq(1, query);
//if (i > 10000)
// break;
}
free_alg(aligns);
show_msg(__func__, "Thread %d finished. \n", d->tid);
}
开发者ID:agongdai,项目名称:peta,代码行数:35,代码来源:correct.c
示例2: recv_buffer
static int recv_buffer(struct connreq *conn) {
int rc = 0;
show_msg(MSGDEBUG, "Reading from server (expecting %d bytes)\n", conn->datalen);
while ((rc == 0) && (conn->datadone != conn->datalen)) {
rc = recv(conn->sockid, conn->buffer + conn->datadone,
conn->datalen - conn->datadone, 0);
if (rc > 0) {
conn->datadone += rc;
rc = 0;
} else if (rc == 0) {
show_msg(MSGDEBUG, "Peer has shutdown but we only read %d of %d bytes.\n",
conn->datadone, conn->datalen);
rc = ENOTCONN; /* ENOTCONN seems like the most fitting error message */
} else {
if (errno != EWOULDBLOCK)
show_msg(MSGDEBUG, "Read failed, %s\n", strerror(errno));
rc = errno;
}
}
if (conn->datadone == conn->datalen)
conn->state = conn->nextstate;
show_msg(MSGDEBUG, "Received %d bytes of %d bytes expected, return code is %d\n",
conn->datadone, conn->datalen, rc);
return(rc);
}
开发者ID:Shouqun,项目名称:tsocks_for_mac,代码行数:28,代码来源:tsocks.c
示例3: handle_path
static int handle_path(struct parsedfile *config, int lineno, int nowords, char *words[]) {
struct serverent *newserver;
if ((nowords != 2) || (strcmp(words[1], "{"))) {
show_msg(MSGERR, "Badly formed path open statement on line %d "
"in configuration file (should look like "
"\"path {\")\n", lineno);
} else if (currentcontext != &(config->defaultserver)) {
/* You cannot nest path statements so check that */
/* the current context is defaultserver */
show_msg(MSGERR, "Path statements cannot be nested on line %d "
"in configuration file\n", lineno);
} else {
/* Open up a new serverent, put it on the list */
/* then set the current context */
if (((int) (newserver = (struct serverent *) malloc(sizeof(struct serverent)))) == -1)
exit(-1);
/* Initialize the structure */
show_msg(MSGDEBUG, "New server structure from line %d in configuration file going "
"to 0x%08x\n", lineno, newserver);
memset(newserver, 0x0, sizeof(*newserver));
newserver->next = config->paths;
newserver->lineno = lineno;
config->paths = newserver;
currentcontext = newserver;
}
return(0);
}
开发者ID:khKhKhEtelKhKhkh,项目名称:torsocks,代码行数:30,代码来源:parser.c
示例4: getpeername
/* If we are not done setting up the connection yet, return
* -1 and ENOTCONN, otherwise call getpeername
*
* This is necessary since some applications, when using non-blocking connect,
* (like ircII) use getpeername() to find out if they are connected already.
*
* This results in races sometimes, where the client sends data to the socket
* before we are done with the socks connection setup. Another solution would
* be to intercept send().
*
* This could be extended to actually set the peername to the peer the
* client application has requested, but not for now.
*
* PP, Sat, 27 Mar 2004 11:30:23 +0100
*/
int getpeername(GETPEERNAME_SIGNATURE) {
struct connreq *conn;
int rc;
if (realgetpeername == NULL) {
show_msg(MSGERR, "Unresolved symbol: getpeername\n");
return(-1);
}
show_msg(MSGDEBUG, "Call to getpeername for fd %d\n", __fd);
rc = realgetpeername(__fd, __name, __namelen);
if (rc == -1)
return rc;
/* Are we handling this connect? */
if ((conn = find_socks_request(__fd, 1))) {
/* While we are at it, we might was well try to do something useful */
handle_request(conn);
if (conn->state != DONE) {
errno = ENOTCONN;
return(-1);
}
}
return rc;
}
开发者ID:Shouqun,项目名称:tsocks_for_mac,代码行数:43,代码来源:tsocks.c
示例5: handle_type
static int handle_type(struct parsedfile *config, int lineno, char *value) {
if (currentcontext->type != 0) {
if (currentcontext == &(config->defaultserver))
show_msg(MSGERR, "Server type may only be specified "
"once for default server, at line %d "
"in configuration file\n", lineno);
else
show_msg(MSGERR, "Server type may only be specified "
"once per path on line %d in configuration "
"file. (Path begins on line %d)\n",
lineno, currentcontext->lineno);
} else {
errno = 0;
currentcontext->type = (int) strtol(value, (char **)NULL, 10);
if ((errno != 0) || (currentcontext->type == 0) ||
((currentcontext->type != 4) && (currentcontext->type != 5))) {
show_msg(MSGERR, "Invalid server type (%s) "
"specified in configuration file "
"on line %d, only 4 or 5 may be "
"specified\n", value, lineno);
currentcontext->type = 0;
}
}
return(0);
}
开发者ID:khKhKhEtelKhKhkh,项目名称:torsocks,代码行数:27,代码来源:parser.c
示例6: our_gethostbyname
struct hostent * our_gethostbyname(dead_pool *pool, const char *name)
{
int pos;
static struct in_addr addr;
static struct hostent he;
static char *addrs[2];
show_msg(MSGDEBUG, "our_gethostbyname: '%s' requested\n", name);
pos = store_pool_entry(pool,(char *) name, &addr);
if(pos == -1) {
h_errno = HOST_NOT_FOUND;
return NULL;
}
addrs[0] = (char *)&addr;
addrs[1] = NULL;
he.h_name = pool->entries[pos].name;
he.h_aliases = NULL;
he.h_length = 4;
he.h_addrtype = AF_INET;
he.h_addr_list = addrs;
show_msg(MSGDEBUG, "our_gethostbyname: resolved '%s' to: '%s'\n",
name, inet_ntoa(*((struct in_addr *)he.h_addr)));
return &he;
}
开发者ID:javerous,项目名称:TorProxifier,代码行数:29,代码来源:dead_pool.c
示例7: parse_socks4a_resolve_response
static int parse_socks4a_resolve_response(const char *response, size_t len, uint32_t *addr_out)
{
uint8_t status;
uint16_t port;
if (len < RESPONSE_LEN) {
show_msg(MSGWARN,"Truncated socks response.\n");
return -1;
}
if (((uint8_t)response[0])!=0) { /* version: 0 */
show_msg(MSGWARN,"Nonzero version in socks response: bad format.\n");
return -1;
}
status = (uint8_t)response[1];
memcpy(&port, response+2, sizeof(port));
if (port!=0) { /* port: 0 */
show_msg(MSGWARN,"Nonzero port in socks response: bad format.\n");
return -1;
}
if (status != 90) {
show_msg(MSGWARN,"Bad status: socks request failed.\n");
return -1;
}
memcpy(addr_out, response+4, sizeof(*addr_out));
return 0;
}
开发者ID:javerous,项目名称:TorProxifier,代码行数:29,代码来源:dead_pool.c
示例8: clock
bwa_seq_t *load_reads(const char *fa_fn, uint32_t *n_seqs) {
bwa_seq_t *seqs, *part_seqs;
bwa_seqio_t *ks;
int n_part_seqs = 0, n_seqs_full = 0, n_seqs_loaded = 0;
clock_t t = clock();
ks = bwa_open_reads(BWA_MODE, fa_fn);
n_seqs_full = N_CHUNK_SEQS;
show_msg(__func__, "Loading reads from library %s...\n", fa_fn);
seqs = (bwa_seq_t*) calloc (N_DF_MAX_SEQS, sizeof(bwa_seq_t));
while ((part_seqs = bwa_read_seq(ks, N_CHUNK_SEQS, &n_part_seqs, BWA_MODE, 0))
!= 0) {
show_msg(__func__, "%d sequences loaded: %.2f sec... \n",
n_seqs_loaded + n_part_seqs, fa_fn, (float) (clock() - t) / CLOCKS_PER_SEC);
pe_reverse_seqs(part_seqs, n_part_seqs);
if ((n_seqs_loaded + n_part_seqs) > n_seqs_full) {
n_seqs_full += n_part_seqs + 2;
kroundup32(n_seqs_full);
seqs = (bwa_seq_t*) realloc(seqs, sizeof(bwa_seq_t) * n_seqs_full);
}
memmove(&seqs[n_seqs_loaded], part_seqs, sizeof(bwa_seq_t) * n_part_seqs);
free(part_seqs);
n_seqs_loaded += n_part_seqs;
}
bwa_seq_close(ks);
if (n_seqs_loaded < 1) {
err_fatal(__func__,
"No sequence in file %s, make sure the format is correct! \n",
fa_fn);
}
*n_seqs = n_seqs_loaded;
return seqs;
}
开发者ID:agongdai,项目名称:peta,代码行数:34,代码来源:rnaseq.c
示例9: read_socksv4_req
static int read_socksv4_req(struct connreq *conn) {
struct sockrep *thisrep;
thisrep = (struct sockrep *) conn->buffer;
if (thisrep->result != 90) {
show_msg(MSGERR, "SOCKS V4 connect rejected:\n");
conn->state = FAILED;
switch(thisrep->result) {
case 91:
show_msg(MSGERR, "SOCKS server refused connection\n");
return(ECONNREFUSED);
case 92:
show_msg(MSGERR, "SOCKS server refused connection "
"because of failed connect to identd "
"on this machine\n");
return(ECONNREFUSED);
case 93:
show_msg(MSGERR, "SOCKS server refused connection "
"because identd and this library "
"reported different user-ids\n");
return(ECONNREFUSED);
default:
show_msg(MSGERR, "Unknown reason\n");
return(ECONNREFUSED);
}
}
conn->state = DONE;
return(0);
}
开发者ID:TamasSzerb,项目名称:tsocks,代码行数:32,代码来源:tsocks.c
示例10: handle_port
static int handle_port(struct parsedfile *config, int lineno, char *value) {
if (currentcontext->port != 0) {
if (currentcontext == &(config->defaultserver))
show_msg(MSGERR, "Server port may only be specified "
"once for default server, at line %d "
"in configuration file\n", lineno);
else
show_msg(MSGERR, "Server port may only be specified "
"once per path on line %d in configuration "
"file. (Path begins on line %d)\n",
lineno, currentcontext->lineno);
} else {
errno = 0;
currentcontext->port = (unsigned short int)
(strtol(value, (char **)NULL, 10));
if ((errno != 0) || (currentcontext->port == 0)) {
show_msg(MSGERR, "Invalid server port number "
"specified in configuration file "
"(%s) on line %d\n", value, lineno);
currentcontext->port = 0;
}
}
return(0);
}
开发者ID:khKhKhEtelKhKhkh,项目名称:torsocks,代码行数:26,代码来源:parser.c
示例11: connect_server
static int connect_server(struct connreq *conn) {
int rc;
/* Connect this socket to the socks server */
show_msg(MSGDEBUG, "Connecting to %s port %d\n",
inet_ntoa(conn->serveraddr.sin_addr), ntohs(conn->serveraddr.sin_port));
rc = realconnect(conn->sockid, (CONNECT_SOCKARG) &(conn->serveraddr),
sizeof(conn->serveraddr));
show_msg(MSGDEBUG, "Connect returned %d, errno is %d\n", rc, errno);
if (rc) {
if (errno != EINPROGRESS) {
show_msg(MSGERR, "Error %d attempting to connect to SOCKS "
"server (%s)\n", errno, strerror(errno));
conn->state = FAILED;
} else {
show_msg(MSGDEBUG, "Connection in progress\n");
conn->state = CONNECTING;
}
} else {
show_msg(MSGDEBUG, "Socket %d connected to SOCKS server\n", conn->sockid);
conn->state = CONNECTED;
}
return((rc ? errno : 0));
}
开发者ID:TamasSzerb,项目名称:tsocks,代码行数:25,代码来源:tsocks.c
示例12: client_receive_smb
static ssize_t client_receive_smb(struct cli_state *cli, size_t maxlen)
{
size_t len;
for(;;) {
NTSTATUS status;
set_smb_read_error(&cli->smb_rw_error, SMB_READ_OK);
status = receive_smb_raw(cli->fd, cli->inbuf, cli->bufsize,
cli->timeout, maxlen, &len);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10,("client_receive_smb failed\n"));
show_msg(cli->inbuf);
if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
set_smb_read_error(&cli->smb_rw_error,
SMB_READ_EOF);
return -1;
}
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
set_smb_read_error(&cli->smb_rw_error,
SMB_READ_TIMEOUT);
return -1;
}
set_smb_read_error(&cli->smb_rw_error, SMB_READ_ERROR);
return -1;
}
/*
* I don't believe len can be < 0 with NT_STATUS_OK
* returned above, but this check doesn't hurt. JRA.
*/
if ((ssize_t)len < 0) {
return len;
}
/* Ignore session keepalive packets. */
if(CVAL(cli->inbuf,0) != SMBkeepalive) {
break;
}
}
if (cli_encryption_on(cli)) {
NTSTATUS status = cli_decrypt_message(cli);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("SMB decryption failed on incoming packet! Error %s\n",
nt_errstr(status)));
cli->smb_rw_error = SMB_READ_BAD_DECRYPT;
return -1;
}
}
show_msg(cli->inbuf);
return len;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:59,代码来源:clientgen.c
示例13: handle_line
static int handle_line(struct parsedfile *config, char *line, int lineno) {
char *words[10];
static char savedline[MAXLINE];
int nowords = 0, i;
/* Save the input string */
strncpy(savedline, line, MAXLINE - 1);
savedline[MAXLINE - 1] = (char) 0;
/* Tokenize the input string */
nowords = tokenize(line, 10, words);
/* Set the spare slots to an empty string to simplify */
/* processing */
for (i = nowords; i < 10; i++)
words[i] = "";
if (nowords > 0) {
/* Now this can either be a "path" block starter or */
/* ender, otherwise it has to be a pair (<name> = */
/* <value>) */
if (!strcmp(words[0], "path")) {
handle_path(config, lineno, nowords, words);
} else if (!strcmp(words[0], "}")) {
handle_endpath(config, lineno, nowords, words);
} else {
/* Has to be a pair */
if ((nowords != 3) || (strcmp(words[1], "="))) {
show_msg(MSGERR, "Malformed configuration pair "
"on line %d in configuration "
"file, \"%s\"\n", lineno, savedline);
} else if (!strcmp(words[0], "reaches")) {
handle_reaches(config, lineno, words[2]);
} else if (!strcmp(words[0], "server")) {
handle_server(config, lineno, words[2]);
} else if (!strcmp(words[0], "server_port")) {
handle_port(config, lineno, words[2]);
} else if (!strcmp(words[0], "server_type")) {
handle_type(config, lineno, words[2]);
} else if (!strcmp(words[0], "default_user")) {
handle_defuser(config, lineno, words[2]);
} else if (!strcmp(words[0], "default_pass")) {
handle_defpass(config, lineno, words[2]);
} else if (!strcmp(words[0], "local")) {
handle_local(config, lineno, words[2]);
} else {
show_msg(MSGERR, "Invalid pair type (%s) specified "
"on line %d in configuration file, "
"\"%s\"\n", words[0], lineno,
savedline);
}
}
}
return(0);
}
开发者ID:Anakros,项目名称:tsocks,代码行数:55,代码来源:parser.c
示例14: send_socksv5_connect
static int send_socksv5_connect(struct connreq *conn) {
#ifdef USE_TOR_DNS
int namelen = 0;
char *name = NULL;
#endif
char constring[] = { 0x05, /* Version 5 SOCKS */
0x01, /* Connect request */
0x00, /* Reserved */
0x01 }; /* IP Version 4 */
show_msg(MSGDEBUG, "Constructing V5 connect request\n");
conn->datadone = 0;
conn->state = SENDING;
conn->nextstate = SENTV5CONNECT;
memcpy(conn->buffer, constring, sizeof(constring));
conn->datalen = sizeof(constring);
#ifdef USE_TOR_DNS
show_msg(MSGDEBUG, "send_socksv5_connect: looking for: %s\n",
inet_ntoa(conn->connaddr.sin_addr));
name = get_pool_entry(pool, &(conn->connaddr.sin_addr));
if(name != NULL) {
namelen = strlen(name);
if(namelen > 255) { /* "Can't happen" */
name = NULL;
}
}
if(name != NULL) {
show_msg(MSGDEBUG, "send_socksv5_connect: found it!\n");
/* Substitute the domain name from the pool into the SOCKS request. */
conn->buffer[3] = 0x03; /* Change the ATYP field */
conn->buffer[4] = namelen; /* Length of name */
conn->datalen++;
memcpy(&conn->buffer[conn->datalen], name, namelen);
conn->datalen += namelen;
} else {
show_msg(MSGDEBUG, "send_socksv5_connect: ip address not found\n");
#endif
/* Use the raw IP address */
memcpy(&conn->buffer[conn->datalen], &(conn->connaddr.sin_addr.s_addr),
sizeof(conn->connaddr.sin_addr.s_addr));
conn->datalen += sizeof(conn->connaddr.sin_addr.s_addr);
#ifdef USE_TOR_DNS
}
#endif
memcpy(&conn->buffer[conn->datalen], &(conn->connaddr.sin_port),
sizeof(conn->connaddr.sin_port));
conn->datalen += sizeof(conn->connaddr.sin_port);
return(0);
}
开发者ID:Shouqun,项目名称:tsocks_for_mac,代码行数:52,代码来源:tsocks.c
示例15: handle_reaches
static int handle_reaches(int lineno, char *value) {
int rc;
struct netent *ent;
rc = make_netent(value, &ent);
switch(rc) {
case 1:
show_msg(MSGERR, "Local network specification (%s) is not validly "
"constructed in reach statement on line "
"%d in configuration "
"file\n", value, lineno);
return(0);
break;
case 2:
show_msg(MSGERR, "IP in reach statement "
"network specification (%s) is not valid on line "
"%d in configuration file\n", value, lineno);
return(0);
break;
case 3:
show_msg(MSGERR, "SUBNET in reach statement "
"network specification (%s) is not valid on "
"line %d in configuration file\n", value,
lineno);
return(0);
break;
case 4:
show_msg(MSGERR, "IP (%s) & ", inet_ntoa(ent->localip));
show_msg(MSGERR, "SUBNET (%s) != IP on line %d in "
"configuration file, ignored\n",
inet_ntoa(ent->localnet), lineno);
return(0);
break;
case 5:
show_msg(MSGERR, "Start port in reach statement "
"network specification (%s) is not valid on line "
"%d in configuration file\n", value, lineno);
return(0);
break;
case 6:
show_msg(MSGERR, "End port in reach statement "
"network specification (%s) is not valid on line "
"%d in configuration file\n", value, lineno);
return(0);
break;
case 7:
show_msg(MSGERR, "End port in reach statement "
"network specification (%s) is less than the start "
"port on line %d in configuration file\n", value,
lineno);
return(0);
break;
}
/* The entry is valid so add it to linked list */
ent -> next = currentcontext -> reachnets;
currentcontext -> reachnets = ent;
return(0);
}
开发者ID:khKhKhEtelKhKhkh,项目名称:torsocks,代码行数:60,代码来源:parser.c
示例16: switch
void STATS_ITEM::sample(double v, bool collecting_stats, double now) {
if (value != v && log_changes) {
char buf[256];
switch (kind) {
case DISK:
sprintf(buf, "%s: %f GB -> %f GB\n", name, value/1e9, v/1e9);
show_msg(buf);
break;
case NETWORK:
sprintf(buf, "%s: %f Mbps -> %f Mbps\n", name, value/1e6, v/1e6);
show_msg(buf);
break;
case FAULT_TOLERANCE:
sprintf(buf, "%s: %.0f -> %.0f\n", name, value, v);
show_msg(buf);
break;
}
}
double old_val = value;
value = v;
if (!collecting_stats) return;
if (first) {
first = false;
prev_t = now;
return;
}
double dt = now - prev_t;
prev_t = now;
integral += dt*old_val;
switch (kind) {
case DISK:
case NETWORK:
if (v > extreme_val) {
extreme_val = v;
extreme_val_time = now;
}
break;
case FAULT_TOLERANCE:
if (v < extreme_val) {
extreme_val = v;
extreme_val_time = now;
}
break;
}
fprintf(f, "%f %f\n", now, old_val);
fprintf(f, "%f %f\n", now, v);
}
开发者ID:AltroCoin,项目名称:altrocoin,代码行数:48,代码来源:stats.cpp
示例17: reply_sesssetup_blob
static BOOL reply_sesssetup_blob(connection_struct *conn, char *outbuf,
DATA_BLOB blob, NTSTATUS nt_status)
{
char *p;
if (!NT_STATUS_IS_OK(nt_status) && !NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
ERROR_NT(nt_status_squash(nt_status));
} else {
set_message(outbuf,4,0,True);
nt_status = nt_status_squash(nt_status);
SIVAL(outbuf, smb_rcls, NT_STATUS_V(nt_status));
SSVAL(outbuf, smb_vwv0, 0xFF); /* no chaining possible */
SSVAL(outbuf, smb_vwv3, blob.length);
p = smb_buf(outbuf);
/* should we cap this? */
memcpy(p, blob.data, blob.length);
p += blob.length;
p += add_signature( outbuf, p );
set_message_end(outbuf,p);
}
show_msg(outbuf);
return send_smb(smbd_server_fd(),outbuf);
}
开发者ID:gittestusername,项目名称:uClinux,代码行数:28,代码来源:sesssetup.c
示例18: get_config
static int get_config () {
static int done = 0;
if (done)
return(0);
/* Determine the location of the config file */
#ifdef ALLOW_ENV_CONFIG
if (!suid)
conffile = getenv("TSOCKS_CONF_FILE");
#endif
/* Read in the config file */
config = malloc(sizeof(*config));
if (!config)
return(0);
read_config(conffile, config);
if (config->paths)
show_msg(MSGDEBUG, "First lineno for first path is %d\n", config->paths->lineno);
done = 1;
return(0);
}
开发者ID:TamasSzerb,项目名称:tsocks,代码行数:25,代码来源:tsocks.c
示例19: main
int main(void)
{
FILE *fp;
std_t *stdp = NULL;
int choice, len;
fp = fopen("student_score", "r+");
if(fp == NULL)
sys_err("fopen student_score");
stdp = get_info(fp, stdp, &len);
while(1){
show_msg(1);
scanf("%d", &choice);
switch(choice){
case 1:display(stdp, len);
break;
case 2:sort(stdp, len, 1);
break;
case 3:insert(stdp, len, fp);
break;
case 4:sort(stdp, len, 2);
free(stdp);
fclose(fp);
return 0;
default:fputs("Invalid choice, rechoose!\n", stdout);
break;
}
}
return 0;
}
开发者ID:akaehy,项目名称:Project,代码行数:32,代码来源:std.c
示例20: send_socksv4_request
static int send_socksv4_request(struct connreq *conn) {
struct passwd *user;
struct sockreq *thisreq;
/* Determine the current username */
user = getpwuid(getuid());
thisreq = (struct sockreq *) conn->buffer;
/* Check the buffer has enough space for the request */
/* and the user name */
conn->datalen = sizeof(struct sockreq) +
(user == NULL ? 0 : strlen(user->pw_name)) + 1;
if (sizeof(conn->buffer) < conn->datalen) {
show_msg(MSGERR, "The SOCKS username is too long");
conn->state = FAILED;
return(ECONNREFUSED);
}
/* Create the request */
thisreq->version = 4;
thisreq->command = 1;
thisreq->dstport = conn->connaddr.sin_port;
thisreq->dstip = conn->connaddr.sin_addr.s_addr;
/* Copy the username */
strcpy((char *) thisreq + sizeof(struct sockreq),
(user == NULL ? "" : user->pw_name));
conn->datadone = 0;
conn->state = SENDING;
conn->nextstate = SENTV4REQ;
return(0);
}
开发者ID:TamasSzerb,项目名称:tsocks,代码行数:35,代码来源:tsocks.c
注:本文中的show_msg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论