00001 /* ///////////////////////////////////////////////////////////////////////////// 00002 * File: examples/cpp/example_c_log_n/example_c_log_n.c 00003 * 00004 * Purpose: C example program for Pantheios. Demonstrates: 00005 * 00006 * - use of pantheios_log_?() in C compilation units 00007 * 00008 * Created: 31st August 2006 00009 * Updated: 2nd September 2006 00010 * 00011 * www: http://www.pantheios.org/ 00012 * 00013 * License: This source code is placed into the public domain 2006 00014 * by Synesis Software Pty Ltd. There are no restrictions 00015 * whatsoever to your use of the software. 00016 * 00017 * This software is provided "as is", and any warranties, 00018 * express or implied, of any kind and for any purpose, are 00019 * disclaimed. 00020 * 00021 * ////////////////////////////////////////////////////////////////////////// */ 00022 00023 00024 /* Pantheios Header Files */ 00025 #include <pantheios/pantheios.h> /* Pantheios C main header */ 00026 00027 /* Standard C Header Files */ 00028 #include <stdio.h> /* for sprintf() */ 00029 #include <stdlib.h> /* for exit codes */ 00030 00031 /* ////////////////////////////////////////////////////////////////////////// */ 00032 00033 /* Define the fe.simple process identity, so that it links when using fe.simple */ 00034 const char FE_SIMPLE_PROCESS_IDENTITY[] = "example_c_log_n"; 00035 00036 /* ////////////////////////////////////////////////////////////////////////// */ 00037 00038 int main() 00039 { 00040 /* Must initialise Pantheios, when using from C (and there are no C++ 00041 * compilation units in the link-unit). 00042 * 00043 * If this is not done, undefined behaviour will ensue ... 00044 */ 00045 if(pantheios_init() < 0) 00046 { 00047 return EXIT_FAILURE; 00048 } 00049 else 00050 { 00051 int numUsers = 1000000; 00052 char szNumUsers[101]; 00053 00054 /* Log a three part statement. Note that specifying -1 00055 * for the length causes the corresponding string argument to be 00056 * interpreted as a nul-terminated string, and its length to be 00057 * calculated (via strlen()); Output: 00058 * "We're sure there're likely to be >00000000000001000000 satisfied users of Pantheios" 00059 */ 00060 pantheios_log_3(PANTHEIOS_SEV_ALERT 00061 , "We're sure there're likely to be >", -1 00062 , szNumUsers, sprintf(&szNumUsers[0], "%020d", numUsers) 00063 , " satisfied users of Pantheios", -1); 00064 00065 /* Must uninitialise Pantheios. 00066 * 00067 * pantheios_uninit() must be called once for each successful (>=0) 00068 * invocation of pantheios_init(). 00069 */ 00070 pantheios_uninit(); 00071 00072 return EXIT_SUCCESS; 00073 } 00074 } 00075 00076 /* ////////////////////////////////////////////////////////////////////////// */
|
|
pantheios Library documentation © Matthew Wilson, 2006 |
|