本文整理汇总了C++中print_timestamp函数的典型用法代码示例。如果您正苦于以下问题:C++ print_timestamp函数的具体用法?C++ print_timestamp怎么用?C++ print_timestamp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_timestamp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: log_garbage
/* Log garbage sent by a client.
*/
void log_garbage(t_session *session) {
int i, spaces = 2;
FILE *fp;
char str[TIMESTAMP_SIZE + IP_ADDRESS_SIZE];
if ((session->config->garbage_logfile == NULL) || (session->request == NULL)) {
return;
}
for (i = 0; i < session->bytes_in_buffer; i++) {
if (session->request[i] == '\0') {
if (spaces > 0) {
session->request[i] = ' ';
spaces--;
} else {
session->request[i] = '\r';
}
}
}
if ((fp = fopen(session->config->garbage_logfile, "a")) == NULL) {
return;
}
ip_to_str(str, &(session->ip_address), IP_ADDRESS_SIZE);
strcat(str, "|");
print_timestamp(str + strlen(str));
fprintf(fp, "%s%s"EOL, str, session->request);
fclose(fp);
}
示例2: accept_msg
int accept_msg(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
FILE *fp = arg;
if (timestamp)
print_timestamp(fp);
switch (n->nlmsg_type) {
case RTM_NEWLINK:
case RTM_DELLINK:
if (prefix_banner)
fprintf(fp, "[LINK]");
return print_linkinfo(who, n, arg);
case RTM_NEWNEIGH:
case RTM_DELNEIGH:
if (prefix_banner)
fprintf(fp, "[NEIGH]");
return print_fdb(who, n, arg);
case 15:
return show_mark(fp, n);
default:
return 0;
}
}
示例3: wiimote_timestamp2logicaltime
static double wiimote_timestamp2logicaltime(t_wiimote*x, struct timespec*timestamp) {
double pddelay=clock_gettimesince(x->baselogicaltime); /* how long in logical time since we have connected to the wii */
double realdelay=0.; /* how long (in ms) after we connected to the wiimote this timestamp appeared */
double delay=0.;
if(NULL==timestamp || NULL==x->basetime)
return 0.; /* immediately */
realdelay=
(timestamp->tv_sec - x->basetime->tv_sec) * 1000. +
(timestamp->tv_nsec - x->basetime->tv_nsec) / 1000000.;
delay=realdelay-pddelay;
#if 0
print_timestamp(timestamp, x->basetime);
post("logical time: %f = %f - %f", clock_gettimesince(x->baselogicaltime), now, x->baselogicaltime);
#endif
//post("diff = %f = %f - %f", realdelay-pddelay, realdelay, pddelay);
if(delay<0) {
return 0.;
}
return realdelay;
}
示例4: xfrm_accept_msg
static int xfrm_accept_msg(const struct sockaddr_nl *who,
struct rtnl_ctrl_data *ctrl,
struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE *)arg;
if (timestamp)
print_timestamp(fp);
if (listen_all_nsid) {
if (ctrl == NULL || ctrl->nsid < 0)
fprintf(fp, "[nsid current]");
else
fprintf(fp, "[nsid %d]", ctrl->nsid);
}
switch (n->nlmsg_type) {
case XFRM_MSG_NEWSA:
case XFRM_MSG_DELSA:
case XFRM_MSG_UPDSA:
case XFRM_MSG_EXPIRE:
xfrm_state_print(who, n, arg);
return 0;
case XFRM_MSG_NEWPOLICY:
case XFRM_MSG_DELPOLICY:
case XFRM_MSG_UPDPOLICY:
case XFRM_MSG_POLEXPIRE:
xfrm_policy_print(who, n, arg);
return 0;
case XFRM_MSG_ACQUIRE:
xfrm_acquire_print(who, n, arg);
return 0;
case XFRM_MSG_FLUSHSA:
xfrm_state_flush_print(who, n, arg);
return 0;
case XFRM_MSG_FLUSHPOLICY:
xfrm_policy_flush_print(who, n, arg);
return 0;
case XFRM_MSG_REPORT:
xfrm_report_print(who, n, arg);
return 0;
case XFRM_MSG_NEWAE:
xfrm_ae_print(who, n, arg);
return 0;
case XFRM_MSG_MAPPING:
xfrm_mapping_print(who, n, arg);
return 0;
default:
break;
}
if (n->nlmsg_type != NLMSG_ERROR && n->nlmsg_type != NLMSG_NOOP &&
n->nlmsg_type != NLMSG_DONE) {
fprintf(fp, "Unknown message: %08d 0x%08x 0x%08x\n",
n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
}
return 0;
}
示例5: accept_msg
int accept_msg(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;
if (timestamp)
print_timestamp(fp);
if (n->nlmsg_type == RTM_NEWROUTE || n->nlmsg_type == RTM_DELROUTE) {
print_route(who, n, arg);
return 0;
}
if (n->nlmsg_type == RTM_NEWLINK || n->nlmsg_type == RTM_DELLINK) {
ll_remember_index(who, n, NULL);
print_linkinfo(who, n, arg);
return 0;
}
if (n->nlmsg_type == RTM_NEWADDR || n->nlmsg_type == RTM_DELADDR) {
print_addrinfo(who, n, arg);
return 0;
}
if (n->nlmsg_type == RTM_NEWNEIGH || n->nlmsg_type == RTM_DELNEIGH) {
print_neigh(who, n, arg);
return 0;
}
if (n->nlmsg_type == RTM_NEWPREFIX) {
print_prefix(who, n, arg);
return 0;
}
if (n->nlmsg_type == RTM_NEWRULE || n->nlmsg_type == RTM_DELRULE) {
print_rule(who, n, arg);
return 0;
}
if (n->nlmsg_type == 15) {
char *tstr;
time_t secs = ((__u32*)NLMSG_DATA(n))[0];
long usecs = ((__u32*)NLMSG_DATA(n))[1];
tstr = asctime(localtime(&secs));
tstr[strlen(tstr)-1] = 0;
fprintf(fp, "Timestamp: %s %lu us\n", tstr, usecs);
return 0;
}
if (n->nlmsg_type == RTM_NEWQDISC ||
n->nlmsg_type == RTM_DELQDISC ||
n->nlmsg_type == RTM_NEWTCLASS ||
n->nlmsg_type == RTM_DELTCLASS ||
n->nlmsg_type == RTM_NEWTFILTER ||
n->nlmsg_type == RTM_DELTFILTER)
return 0;
if (n->nlmsg_type != NLMSG_ERROR && n->nlmsg_type != NLMSG_NOOP &&
n->nlmsg_type != NLMSG_DONE) {
fprintf(fp, "Unknown message: %08x %08x %08x\n",
n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
}
return 0;
}
示例6: double_buffering_wait
// Wait for data to be read or written
void double_buffering_wait( double_buffering *b, which_buffer wh_buff )
{
int i;
ssize_t nbytes;
// Which buffer
aiocb_list *buff = wh_buff == IO_BUFF ? b->io_l : b->comp_l;
#if DEBUG
printf("Waiting for %p\n%d operations issued\nLast chunk: %zu bytes\n",
buff, buff->issued, buff->aiocb_l[buff->issued-1]->aio_nbytes);
fflush(stdout);
#endif
for ( i = 0; i < buff->issued; i++ )
{
buff->aux_l[0] = (struct aiocb *)buff->aiocb_l[i];
#if DEBUG
printf("Waiting for chunk %d (of %d): %zu bytes\n", i, buff->issued, buff->aux_l[0]->aio_nbytes);
printf("Start: "); print_timestamp();
fflush(stdout);
#endif
if ( aio_suspend( buff->aux_l, 1, NULL ) != 0 )
{
// perror("aio_suspend error");
fprintf(stderr, "[ERROR] aio_suspend: %s", strerror(aio_error(buff->aux_l[0])));
exit( EXIT_FAILURE );
}
nbytes = aio_return( (struct aiocb *)buff->aux_l[0] );
if ( nbytes != buff->aux_l[0]->aio_nbytes )
{
fprintf(stderr, "[ERROR] aio_return: %s", strerror(aio_error(buff->aux_l[0])));
// perror("aio_suspend error - data not read completely");
printf("%zu bytes read/write - %zu bytes expected\n", nbytes, buff->aux_l[0]->aio_nbytes);
exit( EXIT_FAILURE );
}
#if DEBUG
printf("End: "); print_timestamp();
fflush(stdout);
#endif
}
}
示例7: np_conn_respond
void
np_conn_respond(Npreq *req)
{
int n;
Npconn *conn;
Nptrans *trans;
Npfcall *rc;
trans = NULL;
conn = req->conn;
rc = req->rcall;
pthread_mutex_lock(&conn->lock);
if (conn->trans && !conn->resetting && rc) {
if (conn->srv->debuglevel) {
print_timestamp(stderr);
fprintf(stderr, " >>> (%p) ", conn);
np_printfcall(stderr, rc, conn->dotu);
if ( req->tcall->encryptor )
fprintf(stderr, " (encrypted)");
fprintf(stderr, "\n");
}
if ( req->tcall->encryptor ) {
/* Request was encrypted => encrypt also the response */
rc->encryptor = req->tcall->encryptor;
rc = np_encrypt_fcall(rc);
req->rcall = rc;
}
n = np_trans_write(conn->trans, rc->pkt, rc->size);
if (n <= 0) {
trans = conn->trans;
conn->trans = NULL;
}
}
np_conn_free_incall(req->conn, req->tcall);
free(req->rcall);
req->tcall = NULL;
req->rcall = NULL;
pthread_mutex_unlock(&conn->lock);
if (conn->resetting) {
pthread_mutex_lock(&conn->srv->lock);
pthread_cond_broadcast(&conn->resetcond);
pthread_mutex_unlock(&conn->srv->lock);
}
if (trans)
np_trans_destroy(trans); /* np_conn_read_proc will take care of resetting */
}
示例8: xfrm_accept_msg
static int xfrm_accept_msg(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;
if (timestamp)
print_timestamp(fp);
if (n->nlmsg_type == XFRM_MSG_NEWSA ||
n->nlmsg_type == XFRM_MSG_DELSA ||
n->nlmsg_type == XFRM_MSG_UPDSA ||
n->nlmsg_type == XFRM_MSG_EXPIRE) {
xfrm_state_print(who, n, arg);
return 0;
}
if (n->nlmsg_type == XFRM_MSG_NEWPOLICY ||
n->nlmsg_type == XFRM_MSG_DELPOLICY ||
n->nlmsg_type == XFRM_MSG_UPDPOLICY ||
n->nlmsg_type == XFRM_MSG_POLEXPIRE) {
xfrm_policy_print(who, n, arg);
return 0;
}
if (n->nlmsg_type == XFRM_MSG_ACQUIRE) {
xfrm_acquire_print(who, n, arg);
return 0;
}
if (n->nlmsg_type == XFRM_MSG_FLUSHSA) {
/* XXX: Todo: show proto in xfrm_usersa_flush */
fprintf(fp, "Flushed state\n");
return 0;
}
if (n->nlmsg_type == XFRM_MSG_FLUSHPOLICY) {
fprintf(fp, "Flushed policy\n");
return 0;
}
if (n->nlmsg_type == XFRM_MSG_REPORT) {
xfrm_report_print(who, n, arg);
return 0;
}
if (n->nlmsg_type == XFRM_MSG_NEWAE) {
xfrm_ae_print(who, n, arg);
return 0;
}
if (n->nlmsg_type != NLMSG_ERROR && n->nlmsg_type != NLMSG_NOOP &&
n->nlmsg_type != NLMSG_DONE) {
fprintf(fp, "Unknown message: %08d 0x%08x 0x%08x\n",
n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
}
return 0;
}
示例9: print_wim_direntry
void
print_wim_direntry (const char *prefix, struct wim_direntry *dir)
{
printf ("%s.length = %" PRIu64 "\n", prefix, dir->length);
printf ("%s.attributes = %" PRIu32, prefix, dir->attributes);
if (dir->attributes) {
printf (" (");
print_wim_file_attributes (dir->attributes);
printf (")");
}
printf ("\n");
printf ("%s.security_id = %" PRIu32 "\n", prefix, dir->security_id);
printf ("%s.subidr_offset = %" PRIu64 "\n", prefix, dir->subdir_offset);
printf ("%s.creation_time = %" PRIi64 " (", prefix, dir->creation_time);
print_timestamp (dir->creation_time);
printf (")\n");
printf ("%s.last_access_time = %" PRIi64 " (", prefix, dir->last_access_time);
print_timestamp (dir->last_access_time);
printf (")\n");
printf ("%s.last_write_time = %" PRIi64 " (", prefix, dir->last_write_time);
print_timestamp (dir->last_write_time);
printf (")\n");
printf ("%s.hash = ", prefix);
print_hex (dir->hash, sizeof (dir->hash));
printf ("\n");
printf ("%s.reparse_tag = %" PRIu32 "\n", prefix, dir->reparse_tag);
printf ("%s.hardlink = %" PRIu64 "\n", prefix, dir->hardlink);
printf ("%s.streams = %" PRIu16 "\n", prefix, dir->streams);
printf ("%s.short_name_length = %" PRIu16 "\n", prefix, dir->short_name_length);
printf ("%s.file_name_length = %" PRIu16 "\n", prefix, dir->file_name_length);
if (dir->file_name_length > 0) {
printf ("%s.filename = ", prefix);
print_utf16 (dir->filename, dir->file_name_length);
printf ("\n");
}
}
示例10: print_headers
static void print_headers(FILE *fp, char *label, struct rtnl_ctrl_data *ctrl)
{
if (timestamp)
print_timestamp(fp);
if (listen_all_nsid) {
if (ctrl == NULL || ctrl->nsid < 0)
fprintf(fp, "[nsid current]");
else
fprintf(fp, "[nsid %d]", ctrl->nsid);
}
if (prefix_banner)
fprintf(fp, "%s", label);
}
示例11: log_unban
/* Log an unbanning.
*/
void log_unban(char *logfile, t_ip_addr *ip_address, unsigned long connect_attempts) {
FILE *fp;
char str[TIMESTAMP_SIZE + IP_ADDRESS_SIZE];
if ((logfile == NULL) || (ip_address == NULL)) {
return;
} else if ((fp = fopen(logfile, "a")) == NULL) {
return;
}
ip_to_str(str, ip_address, IP_ADDRESS_SIZE);
strcat(str, "|");
print_timestamp(str + strlen(str));
fprintf(fp, "%sUnbanned (%ld connect attempts during ban)"EOL, str, connect_attempts);
fclose(fp);
}
示例12: RMDBGLOG_implementation
void RMDBGLOG_implementation(RMbool active,const RMascii *filename,RMint32 line,const RMascii *text,...)
{
if (active && (verbose_stderr != 0)) {
va_list ap;
snprintf((char *)str,RMDBG_MAX_STRING,"[%s:%ld] ", (char *)filename,line);
va_start(ap, text);
vsnprintf((char *)(str+strlen(str)), RMDBG_MAX_STRING-strlen(str), text, ap);
va_end(ap);
print_timestamp(NORMALMSG);
fprintf(NORMALMSG,str);
fflush(NORMALMSG);
}
}
示例13: form_command
lcb_error_t form_command(lcb_error_t err, lcb_t instance, const char * const key, const int count) {
lcb_store_cmd_t cmd;
const lcb_store_cmd_t* commands[1];
commands[0] = &cmd;
memset(&cmd, 0, sizeof(cmd));
cmd.v.v0.operation = LCB_SET;
cmd.v.v0.key = "foo";
if (key) cmd.v.v0.key = key;
cmd.v.v0.nkey = 3;
cmd.v.v0.bytes = "bar";
cmd.v.v0.nbytes = 3;
print_timestamp();
for (int i=0; i < count; i++)
err = lcb_store(instance, NULL, 1, commands);
return err;
}
示例14: xfrm_accept_msg
static int xfrm_accept_msg(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;
if (timestamp)
print_timestamp(fp);
switch (n->nlmsg_type) {
case XFRM_MSG_NEWSA:
case XFRM_MSG_DELSA:
case XFRM_MSG_UPDSA:
case XFRM_MSG_EXPIRE:
xfrm_state_print(who, n, arg);
return 0;
case XFRM_MSG_NEWPOLICY:
case XFRM_MSG_DELPOLICY:
case XFRM_MSG_UPDPOLICY:
case XFRM_MSG_POLEXPIRE:
xfrm_policy_print(who, n, arg);
return 0;
case XFRM_MSG_ACQUIRE:
xfrm_acquire_print(who, n, arg);
return 0;
case XFRM_MSG_FLUSHSA:
xfrm_state_flush_print(who, n, arg);
return 0;
case XFRM_MSG_FLUSHPOLICY:
xfrm_policy_flush_print(who, n, arg);
return 0;
case XFRM_MSG_REPORT:
xfrm_report_print(who, n, arg);
return 0;
case XFRM_MSG_NEWAE:
xfrm_ae_print(who, n, arg);
return 0;
default:
break;
}
if (n->nlmsg_type != NLMSG_ERROR && n->nlmsg_type != NLMSG_NOOP &&
n->nlmsg_type != NLMSG_DONE) {
fprintf(fp, "Unknown message: %08d 0x%08x 0x%08x\n",
n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
}
return 0;
}
示例15: log_cgi_error
/* Log a CGI error.
*/
void log_cgi_error(t_session *session, char *mesg) {
FILE *fp;
char *c, str[TIMESTAMP_SIZE + IP_ADDRESS_SIZE];
int len = 0;
if ((session->host->error_logfile == NULL) || (mesg == NULL)) {
return;
}
c = mesg;
while (*c != '\0') {
if (*c == '\n') {
if (*(c + 1) == '\0') {
*c = '\0';
} else {
*c = '|';
}
} else {
len++;
}
c++;
}
if (len == 0) {
return;
}
if ((fp = fopen(session->host->error_logfile, "a")) == NULL) {
return;
}
if (session->config->anonymize_ip) {
anonymized_ip_to_str(&(session->ip_address), str, IP_ADDRESS_SIZE);
} else {
ip_to_str(&(session->ip_address), str, IP_ADDRESS_SIZE);
}
strcat(str, "|");
print_timestamp(str + strlen(str));
if (session->file_on_disk == NULL) {
fprintf(fp, "%s-|%s"EOL, str, secure_string(mesg));
} else {
fprintf(fp, "%s%s|%s"EOL, str, session->file_on_disk, secure_string(mesg));
}
fclose(fp);
}