本文整理汇总了C++中printfd函数的典型用法代码示例。如果您正苦于以下问题:C++ printfd函数的具体用法?C++ printfd怎么用?C++ printfd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printfd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_cmdline_by_pid
void get_cmdline_by_pid(struct procinfo *pi)
{
char cmd_path[128];
char cmd[256];
char resolved[256];
FILE *fp;
memset(cmd_path, 0, 128);
memset(cmd, 0, 256);
sprintf(cmd_path, "/proc/%d/cmdline", pi->pi_pid);
fp = fopen(cmd_path, "r");
fgets(cmd, 256, fp);
/*resolve all symlinks */
check_target_path((u_char *) cmd, pi->pi_perm);
memset(cmd, 0, 256);
memcpy(cmd, pi->pi_perm->p_full_path,
strlen((const char *)pi->pi_perm->p_full_path));
strcpy((char *)pi->pi_perm->p_full_path, realpath(cmd, resolved));
#if 0
printfd(2, DEBUG "cmdline path : %s\n", cmd_path);
printfd(2, DEBUG "cmd is : %s\n", pi->pi_perm->p_full_path);
#endif
}
示例2: sys_epoll_ctl
int
sys_epoll_ctl(struct tcb *tcp)
{
if (entering(tcp)) {
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
printxval(epollctls, tcp->u_arg[1], "EPOLL_CTL_???");
tprints(", ");
printfd(tcp, tcp->u_arg[2]);
tprints(", ");
if (tcp->u_arg[3] == 0)
tprints("NULL");
else {
#ifdef HAVE_SYS_EPOLL_H
struct epoll_event ev;
if (
#ifdef EPOLL_CTL_DEL
(tcp->u_arg[1] != EPOLL_CTL_DEL) &&
#endif
umove(tcp, tcp->u_arg[3], &ev) == 0)
print_epoll_event(&ev);
else
#endif
tprintf("%lx", tcp->u_arg[3]);
}
}
return 0;
}
示例3: sys_sendfile
int
sys_sendfile(struct tcb *tcp)
{
if (entering(tcp)) {
off_t offset;
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
printfd(tcp, tcp->u_arg[1]);
tprints(", ");
if (!tcp->u_arg[2])
tprints("NULL");
//FIXME: obviously bogus.
//Probably should use explicit long.
//Arches with long long offset param should use
//sys_sendfile64, not this fn.
else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
tprintf("%#lx", tcp->u_arg[2]);
else
#ifdef HAVE_LONG_LONG_OFF_T
tprintf("[%llu]", offset);
#else
tprintf("[%lu]", offset);
#endif
tprintf(", %lu", tcp->u_arg[3]);
}
return 0;
}
示例4: printpair_fd
static void
printpair_fd(struct tcb *tcp, const int i0, const int i1)
{
tprints("[");
printfd(tcp, i0);
tprints(", ");
printfd(tcp, i1);
tprints("]");
}
示例5: lock
//-----------------------------------------------------------------------------
void USER_IMPL::Run()
{
STG_LOCKER lock(&mutex);
if (stgTime > static_cast<time_t>(lastWriteStat + settings->GetStatWritePeriod()))
{
printfd(__FILE__, "USER::WriteStat user=%s\n", GetLogin().c_str());
WriteStat();
}
if (creditExpire.ConstData() && creditExpire.ConstData() < stgTime)
{
WriteServLog("User: %s. Credit expired.", login.c_str());
credit = 0;
creditExpire = 0;
WriteConf();
}
if (passive.ConstData()
&& (stgTime % 30 == 0)
&& (passiveTime.ModificationTime() != stgTime))
{
passiveTime = passiveTime + (stgTime - passiveTime.ModificationTime());
printfd(__FILE__, "===== %s: passiveTime=%d =====\n", login.c_str(), passiveTime.ConstData());
}
if (!authorizedBy.empty())
{
if (connected)
property.Stat().lastActivityTime = stgTime;
if (!connected && IsInetable())
Connect();
if (connected && !IsInetable())
{
if (disabled)
Disconnect(false, "disabled");
else if (passive)
Disconnect(false, "passive");
else
Disconnect(false, "no cash");
}
if (stgTime - lastScanMessages > 10)
{
ScanMessage();
lastScanMessages = stgTime;
}
}
else
{
if (connected)
Disconnect(false, "not authorized");
}
}
示例6: it
//-----------------------------------------------------------------------------
void USER_IMPL::ScanMessage()
{
// No lock `cause we are already locked from caller
// We need not check for the authorizedBy `cause it has already checked by caller
std::list<STG_MSG>::iterator it(messages.begin());
while (it != messages.end())
{
if (settings->GetMessageTimeout() > 0 &&
difftime(stgTime, it->header.creationTime) > settings->GetMessageTimeout())
{
// Timeout exceeded
if (store->DelMessage(it->header.id, login))
{
WriteServLog("Error deleting message: '%s'", store->GetStrError().c_str());
printfd(__FILE__, "Error deleting message: '%s'\n", store->GetStrError().c_str());
}
messages.erase(it++);
continue;
}
if (it->GetNextSendTime() <= stgTime)
{
if (SendMessage(*it))
{
// We need to check all messages in queue for timeout
++it;
continue;
}
if (it->header.repeat < 0)
{
if (store->DelMessage(it->header.id, login))
{
WriteServLog("Error deleting message: '%s'", store->GetStrError().c_str());
printfd(__FILE__, "Error deleting message: '%s'\n", store->GetStrError().c_str());
}
messages.erase(it++);
}
else
{
if (store->EditMessage(*it, login))
{
WriteServLog("Error modifying message: '%s'", store->GetStrError().c_str());
printfd(__FILE__, "Error modifying message: '%s'\n", store->GetStrError().c_str());
}
++it;
}
}
else
{
++it;
}
}
}
示例7: do_dup2
static int
do_dup2(struct tcb *tcp, int flags_arg)
{
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
printfd(tcp, tcp->u_arg[1]);
if (flags_arg >= 0) {
tprints(", ");
printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
}
return RVAL_DECODED | RVAL_FD;
}
示例8: sys_sendfile64
int
sys_sendfile64(struct tcb *tcp)
{
if (entering(tcp)) {
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
printfd(tcp, tcp->u_arg[1]);
tprints(", ");
print_loff_t(tcp, tcp->u_arg[2]);
tprintf(", %lu", tcp->u_arg[3]);
}
return 0;
}
示例9: do_dup2
static int
do_dup2(struct tcb *tcp, int flags_arg)
{
if (entering(tcp)) {
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
printfd(tcp, tcp->u_arg[1]);
if (flags_arg >= 0) {
tprints(", ");
printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
}
}
return 0;
}
示例10: print_mmap
static int
print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset)
{
if (entering(tcp)) {
/* addr */
if (!u_arg[0])
tprints("NULL, ");
else
tprintf("%#lx, ", u_arg[0]);
/* len */
tprintf("%lu, ", u_arg[1]);
/* prot */
printflags(mmap_prot, u_arg[2], "PROT_???");
tprints(", ");
/* flags */
#ifdef MAP_TYPE
printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
#else
printflags(mmap_flags, u_arg[3], "MAP_???");
#endif
tprints(", ");
/* fd */
printfd(tcp, u_arg[4]);
/* offset */
tprintf(", %#llx", offset);
}
return RVAL_HEX;
}
示例11: decode_sockname
static int
decode_sockname(struct tcb *tcp)
{
int ulen, rlen;
if (entering(tcp)) {
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
if (fetch_socklen(tcp, &ulen, tcp->u_arg[1], tcp->u_arg[2])) {
set_tcb_priv_ulong(tcp, ulen);
return 0;
} else {
printaddr(tcp->u_arg[1]);
tprints(", ");
printaddr(tcp->u_arg[2]);
return RVAL_DECODED;
}
}
ulen = get_tcb_priv_ulong(tcp);
if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &rlen) < 0) {
printaddr(tcp->u_arg[1]);
tprintf(", [%d]", ulen);
} else {
decode_sockaddr(tcp, tcp->u_arg[1], ulen > rlen ? rlen : ulen);
if (ulen != rlen)
tprintf(", [%d->%d]", ulen, rlen);
else
tprintf(", [%d]", rlen);
}
return RVAL_DECODED;
}
示例12: do_accept
static int
do_accept(struct tcb *tcp, int flags_arg)
{
if (entering(tcp)) {
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
return 0;
}
if (!tcp->u_arg[2])
tprintf("%#lx, NULL", tcp->u_arg[1]);
else {
int len;
if (tcp->u_arg[1] == 0 || syserror(tcp)
|| umove(tcp, tcp->u_arg[2], &len) < 0) {
tprintf("%#lx", tcp->u_arg[1]);
} else {
printsock(tcp, tcp->u_arg[1], len);
}
tprints(", ");
printnum_int(tcp, tcp->u_arg[2], "%u");
}
if (flags_arg >= 0) {
tprints(", ");
printflags(sock_type_flags, tcp->u_arg[flags_arg],
"SOCK_???");
}
return 0;
}
示例13: socksserver_disconnect_client
// forced == 1
static void socksserver_disconnect_client(socksserver* srv, int fd, int forced) {
fdinfo* client = &srv->clients[fdindex(fd)];
int fdflag = 0;
if(CONFIG_LOG && srv->log) {
logstart();
printfd(fd);
LOGPUT(1, VARISL(" disconnect, forced: "), VARII(forced), NULL);
}
if(forced) rocksockserver_disconnect_client(&srv->serva, fd);
client->state = SS_DISCONNECTED;
if(client->data) {
client->data->state = BS_UNUSED;
client->data->start = 0;
client->data->used = 0;
}
if(client->target_fd != -1) fdflag = 1;
fd = client->target_fd;
client->target_fd = -1;
if(fdflag) {
srv->clients[fdindex(fd)].target_fd = -1;
socksserver_disconnect_client(srv, fd, 1);
}
}
示例14: sys_read
int
sys_read(struct tcb *tcp)
{
struct socket_info sockinfo;
if (entering(tcp)) {
json_object_object_add(tcp->json, "fd", json_object_new_int((int)tcp->u_arg[0]));
printfd(tcp, tcp->u_arg[0]);
tprintf(", ");
if (output_json) {
if (get_socket_info(tcp->pid, (int) tcp->u_arg[0], &sockinfo) == 0) {
append_to_json(tcp->json, &sockinfo);
} else {
json_object_object_add(tcp->json, "pid", json_object_new_int(tcp->pid));
}
}
} else {
/* exiting... */
if (syserror(tcp)) {
tprintf("%#lx", tcp->u_arg[1]);
} else {
/* no error */
if (output_json) {
json_object_object_add(tcp->json, "content",
json_object_new_string(readstr(tcp, tcp->u_arg[1], tcp->u_arg[2])));
json_object_object_add(tcp->json, "length", json_object_new_int(tcp->u_arg[2]));
} else {
printstr(tcp, tcp->u_arg[1], tcp->u_rval);
}
}
tprintf(", %lu", tcp->u_arg[2]);
}
return 0;
}
示例15: clone_circles
static struct ia_circles *_core_mutate(struct ia_circles *circles, int idx)
{
struct ia_circles *mutated_circles = clone_circles(circles);
int max_tries = 0;
//const int ult_max_tries = circles->num_circles * 2;
const int ult_max_tries = 30;
while(max_tries < ult_max_tries) {
printfd("Mutating circle %d/%d\n",
idx,
circles->num_circles);
struct ia_circles *circles_prev = clone_circles(mutated_circles);
_ia_random_action(&mutated_circles->circles[idx], true);
refresh_circles(mutated_circles);
refresh_circles(circles_prev);
struct img_bitmap *_img = mutated_circles->img;
struct img_bitmap *_img_prev = circles_prev->img;
if((_img->score - _img_prev->score) > 0) {
max_tries++;
memcpy(&mutated_circles->circles[idx],
&circles_prev->circles[idx],
sizeof(struct ia_circle));
refresh_circles(mutated_circles);
} else {
max_tries = ult_max_tries;
}
free_circles(circles_prev);
free(circles_prev);
}
refresh_circles(mutated_circles);
return mutated_circles;
}