本文整理汇总了C++中sendf函数的典型用法代码示例。如果您正苦于以下问题:C++ sendf函数的具体用法?C++ sendf怎么用?C++ sendf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: peer
/// Accept an incoming connection
int RASocket::open(void* )
{
if (reactor ()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1)
{
sLog.outError ("RASocket::open: unable to register client handler errno = %s", ACE_OS::strerror (errno));
return -1;
}
ACE_INET_Addr remote_addr;
if (peer ().get_remote_addr (remote_addr) == -1)
{
sLog.outError ("RASocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror (errno));
return -1;
}
sLog.out(LOG_RA, "Incoming connection from %s.",remote_addr.get_host_addr());
///- print Motd
sendf(sWorld.GetMotd());
sendf("\r\n");
sendf(sObjectMgr.GetMangosStringForDBCLocale(LANG_RA_USER));
return 0;
}
示例2: connected
static void
connected(server *s)
{
/* Server successfully connected, send IRC init messages */
connection_thread *ct = s->connecting;
if ((pthread_join(ct->tid, NULL)))
fatal("pthread_join");
if (*ct->ipstr)
newlinef(s->channel, 0, "--", "Connected to [%s]", ct->ipstr);
else
newlinef(s->channel, 0, "--", "Error determining server IP: %s", ct->error);
s->soc = ct->socket;
/* Set reconnect parameters to 0 in case this was an auto-reconnect */
s->reconnect_time = 0;
s->reconnect_delta = 0;
s->latency_time = time(NULL);
s->latency_delta = 0;
sendf(NULL, s, "NICK %s", s->nick);
sendf(NULL, s, "USER %s 8 * :%s", config.username, config.realname);
//FIXME: should the server send nick as is? compare the nick when it's received?
//or should auto_nick take a server argument and write to a buffer of NICKSIZE length?
}
示例3: take_obj_list
void take_obj_list(struct char_data *ch,struct obj_data *o,int *amount,struct char_data *give_to)
{
char buf[MAX_STRING_LENGTH];
if (*amount<=0 && !o) return;
if (o->contains)
take_obj_list(ch,o->contains,amount,give_to);
else if (o->next_content)
take_obj_list(ch,o->next_content,amount,give_to);
else {
if (o->carried_by)
obj_from_char(o);
if (o->in_obj)
obj_from_obj(o);
*amount -= o->obj_flags.cost;
sendf(ch,"Your %s is taken.\n",o->short_description);
if (give_to)
sendf(give_to,"You take his %s.\n",o->short_description);
if (give_to) {
sprintf(buf,"FINE: %d take from %s",o->virtual,GET_NAME(ch));
slog(buf);
obj_to_char(o,give_to);
o->held_for=mystrdup(GET_NAME(ch));
} else {
sprintf(buf,"LINK: %d take from %s",o->virtual,GET_NAME(ch));
slog(buf);
extract_obj(o);
}
}
示例4: cmd_script
unsigned int cmd_script(callbackp *callbacki)
{
char *domain = CONFIG_VAL(Server, domain, callbacki->g_ape->srv);
char *script = NULL;
int alloc = 0;
APE_PARAMS_INIT();
if (domain == NULL) {
send_error(callbacki->call_user, "NO_DOMAIN", "201", callbacki->g_ape);
} else {
char *autodom;
if (strcmp(domain, "auto") == 0 && (autodom = JSTR(domain)) != NULL) {
domain = autodom;
#if 0
/* http://geekandpoke.typepad.com/.a/6a00d8341d3df553ef0120a6d65b8a970b-pi */
struct _http_header_line *hlines;
for (hlines = callbacki->client->http.hlines; hlines != NULL; hlines = hlines->next) {
if (strcasecmp(hlines->key.val, "host") == 0) {
char *loc;
char *newdom = xmalloc(sizeof(char) * (hlines->value.len + 1));
memset(newdom, '\0', hlines->value.len + 1);
if ((loc = strrchr(hlines->value.val, '.')) != NULL) {
int i, pos = 0;
for (i = 0; i < hlines->value.len; i++, pos++) {
newdom[pos] = hlines->value.val[i];
if (newdom[pos] == ':') {
newdom[pos] = '\0';
break;
}
if (hlines->value.val[i] == '.' && &hlines->value.val[i] < loc) {
pos = -1;
}
}
newdom[pos] = '\0';
domain = newdom;
alloc = 1;
}
}
}
#endif
}
sendf(callbacki->client->fd, callbacki->g_ape, "%s<html>\n<head>\n\t<script>\n\t\tdocument.domain=\"%s\"\n\t</script>\n", HEADER_DEFAULT, domain);
if (alloc) {
free(domain);
}
JFOREACH(scripts, script) {
sendf(callbacki->client->fd, callbacki->g_ape, "\t<script type=\"text/javascript\" src=\"%s\"></script>\n", script);
}
sendbin(callbacki->client->fd, "</head>\n<body>\n</body>\n</html>", 30, 0, callbacki->g_ape);
}
示例5: get_file
/* Send one file. */
static void get_file(int s, char *url)
{
/* Set www_dir to point to your web directory. */
char *www_dir = NULL;
char bufo[512];
int n, w;
const char *mime = NULL;
const char *p = url + 1;
if (*p == 0)
p = "index.html";
char *p2 = strrchr(p, '.');
if (p2) {
p2++;
if (!strcmp(p2, "html")) mime = "text/html";
else if (!strcmp(p2, "htm")) mime = "text/html";
else if (!strcmp(p2, "css")) mime = "text/css";
else if (!strcmp(p2, "txt")) mime = "text/plain";
else if (!strcmp(p2, "png")) mime = "image/png";
else if (!strcmp(p2, "jpg")) mime = "image/jpg";
else if (!strcmp(p2, "class")) mime = "application/x-java-applet";
else if (!strcmp(p2, "jar")) mime = "application/java-archive";
else if (!strcmp(p2, "pdf")) mime = "application/pdf";
else if (!strcmp(p2, "swf")) mime = "application/x-shockwave-flash";
else if (!strcmp(p2, "ico")) mime = "image/vnd.microsoft.icon";
else if (!strcmp(p2, "js")) mime = "text/javascript";
}
www_dir = getenv("www_dir");
snprintf(bufo, sizeof(bufo), "%s/%s", www_dir, p);
FILE *f = fopen(bufo, "rb");
if (!f) {
sendf(s, "HTTP/1.0 404 NOK\r\n\r\n");
return;
}
sendf(s, "HTTP/1.0 200 OK\r\n");
if (mime)
sendf(s, "Content-Type: %s\r\n\r\n", mime);
else
sendf(s, "\r\n");
while ((n = fread(bufo, 1, sizeof(bufo), f)) > 0)
if ((w = mysend(s, bufo, n)) < 0)
break;
fclose(f);
}
示例6: cmd_script
unsigned int cmd_script(callbackp *callbacki)
{
char *domain = CONFIG_VAL(Server, domain, callbacki->g_ape->srv);
if (domain == NULL) {
send_error(callbacki->call_user, "NO_DOMAIN", "201", callbacki->g_ape);
} else {
int i;
sendf(callbacki->fdclient, callbacki->g_ape, "%s<html>\n<head>\n\t<script>\n\t\tdocument.domain=\"%s\"\n\t</script>\n", HEADER, domain);
for (i = 1; i <= callbacki->nParam; i++) {
sendf(callbacki->fdclient, callbacki->g_ape, "\t<script type=\"text/javascript\" src=\"%s\"></script>\n", callbacki->param[i]);
}
sendbin(callbacki->fdclient, "</head>\n<body>\n</body>\n</html>", 30, callbacki->g_ape);
}
return (FOR_NOTHING);
}
示例7: forwardsegToSRT
//SNP process uses this function to send a sendseg_arg_t structure which contains a segment and its src node ID to the SRT process.
//Parameter tran_conn is the TCP descriptor of the connection between the SRT process and the SNP process.
//Return 1 if a sendseg_arg_t is succefully sent, otherwise return -1.
int forwardsegToSRT(int tran_conn, int src_nodeID, seg_t* segPtr)
{
sendseg_arg_t a;
a.nodeID = src_nodeID;
memcpy(&a.seg, segPtr, sizeof(seg_t));
return sendf(&a, tran_conn);
}
示例8: snp_sendseg
//SRT process uses this function to send a segment and its destination node ID in a sendseg_arg_t structure to SNP process to send out.
//Parameter network_conn is the TCP descriptor of the connection between the SRT process and the SNP process.
//Return 1 if a sendseg_arg_t is succefully sent, otherwise return -1.
int snp_sendseg(int network_conn, int dest_nodeID, seg_t* segPtr)
{
sendseg_arg_t a;
a.nodeID = dest_nodeID;
memcpy(&a.seg, segPtr, sizeof(seg_t));
return sendf(&a, network_conn);
}
示例9: command_debug_ping
void
command_debug_ping(uint32_t *args)
{
uint8_t len = args[0];
char *data = (void*)(size_t)args[1];
sendf("pong data=%*s", len, data);
}
示例10: command_debug_read8
void
command_debug_read8(uint32_t *args)
{
uint8_t *ptr = (void*)(size_t)args[0];
uint16_t v = *ptr;
sendf("debug_result val=%hu", v);
}
示例11: PyErr_SetString
static PyObject *sendAuthChallenge(PyObject *self, PyObject *args)
{
//cn, domain, reqid, publicKey
//return answer to challenge
int cn;
char *domain;
uint id;
char *publicKey;
server::clientinfo *ci;
if(!PyArg_ParseTuple(args, "isIs", &cn, &domain, &id, &publicKey))
return 0;
ci = server::getinfo(cn);
if(!ci)
{
PyErr_SetString(PyExc_ValueError, "Invalid cn specified");
return 0;
}
uint seed[3] = { randomMT(), randomMT(), randomMT() };
vector<char> challengeBuf;
vector<char> answerBuf;
void *parsedKey = parsepubkey(publicKey);
genchallengestr(parsedKey, seed, sizeof(seed), challengeBuf, answerBuf);
freepubkey(parsedKey);
sendf(ci->clientnum, 1, "risis", N_AUTHCHAL, domain, id, challengeBuf.getbuf());
return Py_BuildValue("s", answerBuf.getbuf());
}
示例12: basic_auth
int basic_auth (SOCKET s )
{
char *cred, *user = relay_user, *pass= relay_pass;
int len, ret;
char * userpass= NULL;
if (user == NULL)
{
g_error("Cannot decide username for proxy authentication.(%s,%d)",__FILE__, __LINE__);
return -1;
}
if (pass == NULL)
{
g_error("Can not decide password for proxy authentication.(%s,%d)", __FILE__, __LINE__);
}
// if ((pass = determine_relay_password ()) == NULL &&
// (pass = readpass("Enter proxy authentication password for %[email protected]%s: ",
//relay_user, relay_host)) == NULL)
// g_error("Cannot decide password for proxy authentication.");
len = strlen(user)+strlen(pass)+1;
userpass = xmalloc(len+1);
snprintf(userpass, len+1, "%s:%s", user, pass);
//memset (pass, 0, strlen(pass));
cred = make_base64_string(userpass);
memset (userpass, 0, len);
ret = sendf(s, "Proxy-Authorization: Basic %s\r\n", cred);
memset(cred, 0, strlen(cred));
free(cred);
return ret;
}
示例13: check_latency
static int
check_latency(server *s, time_t t)
{
/* Check time since last message */
time_t delta;
if (s->soc < 0)
return 0;
delta = t - s->latency_time;
/* Server has timed out */
if (delta > SERVER_TIMEOUT_S) {
server_disconnect(s, 1, 0, "Ping timeout (" STR(SERVER_TIMEOUT_S) ")");
return 1;
}
/* Server might be timing out, attempt to PING */
if (delta > SERVER_LATENCY_PING_S && !s->pinging) {
sendf(NULL, s, "PING :%s", s->host);
s->pinging = 1;
}
/* Server hasn't responded to PING, display latency in status */
if (delta > SERVER_LATENCY_S && ccur->server == s) {
s->latency_delta = delta;
draw(D_STATUS);
}
return 0;
}
示例14: command_debug_read16
void
command_debug_read16(uint32_t *args)
{
uint16_t *ptr = (void*)(size_t)args[0];
irqstatus_t flag = irq_save();
uint16_t v = *ptr;
irq_restore(flag);
sendf("debug_result val=%hu", v);
}
示例15: zappy_connect_nbr
int zappy_connect_nbr(t_fds *c, char *_)
{
t_player *p;
(void)_;
if (!c || !(p = *(t_player**)c) || !p->team)
return (false);
sendf(c, "%d", p->team->max_conn);
return (true);
}