FreeCalypso > hg > themwi-system-sw
view smpp-trx-sa/log.c @ 268:d6630a2d6e80
doc: beginning of numbering plan documentation
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 13 Nov 2023 18:20:57 -0800 |
parents | f1c024b2b835 |
children |
line wrap: on
line source
/* * This module implements smpp-trx-sa log file output. */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <time.h> extern FILE *logF; extern char fmt_time[]; extern int init_done; void log_fatal_error(cause) char *cause; { if (!init_done) return; fprintf(logF, "\n%s %s\n", fmt_time, cause); } static void pdu_hexdump(pdu, pdulen) u_char *pdu; unsigned pdulen; { unsigned off, chunk; int i, c; for (off = 0; off < pdulen; off += chunk) { fprintf(logF, "%04X: ", off); chunk = pdulen - off; if (chunk > 16) chunk = 16; for (i = 0; i < 16; i++) { if (i < chunk) fprintf(logF, "%02X ", pdu[off + i]); else fputs(" ", logF); if (i == 7 || i == 15) putc(' ', logF); } for (i = 0; i < chunk; i++) { c = pdu[off + i]; if (c < ' ' || c > '~') c = '.'; putc(c, logF); } putc('\n', logF); } } void log_rx_pdu(pdu, pdulen) u_char *pdu; unsigned pdulen; { fprintf(logF, "\n%s Received PDU:\n", fmt_time); pdu_hexdump(pdu, pdulen); } void log_sent_pdu(pdu, pdulen) u_char *pdu; unsigned pdulen; { fprintf(logF, "\n%s Sent PDU:\n", fmt_time); pdu_hexdump(pdu, pdulen); }