libjf API reference guide

Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

jf_trace.c

Go to the documentation of this file.
00001 /* 00002 * Copyright 2005 Tiian 00003 * {In real life Tiian is Christian Ferrari} 00004 * This file is part of "libjf" package. 00005 * 00006 * "libjf" is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * "libjf" is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with ; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 #include <jf/jf_config.h> 00021 00022 00023 00024 #ifdef HAVE_STDARG_H 00025 # include <stdarg.h> 00026 #endif 00027 #ifdef HAVE_STDIO_H 00028 # include <stdio.h> 00029 #endif 00030 00031 #include <jf/jf_trace.h> 00032 00033 00034 00035 int jf_trace(const char *fmt, ...) 00036 { 00037 va_list args; 00038 00039 va_start(args, fmt); 00040 #ifdef HAVE_VFPRINTF 00041 vfprintf(stderr, fmt, args); 00042 #else 00043 # error "vfprintf is necessary for jf_trace function!" 00044 #endif 00045 va_end(args); 00046 return 0; 00047 } 00048 00049 00050 00051 void jf_trace_hex_data(const byte_t *data, jf_word_t size, 00052 FILE *out_stream) 00053 { 00054 jf_word_t i; 00055 00056 for (i = 0; i < size; ++i) { 00057 fprintf(out_stream, "%02x ", (data[i] & 0xff)); 00058 } /* for (i = 0; i < size; ++i) */ 00059 } 00060 00061 00062 00063 void jf_trace_text_data(const byte_t *data, jf_word_t size, 00064 FILE *out_stream) 00065 { 00066 jf_word_t i; 00067 00068 for (i = 0; i < size; ++i) { 00069 if (data[i] >= (byte_t)' ' && data[i] < (byte_t)0x80) 00070 putc((int)(data[i] & 0xff), out_stream); 00071 else 00072 putc((int)' ', out_stream); 00073 } /* for (i = 0; i < size; ++i) */ 00074 } 00075 00076 00077

Copyright 2005 © Tiian