#include "l2.h" #define SZ_LOGSTRING "String LogTest c'est deja la.\n" /*--------------------------------------------------------*/ /* void throw(char *pszError) */ /* Quick exception kludge */ /*--------------------------------------------------------*/ void throw(char *pszError) { fprintf(stderr, pszError); exit(1); } /*--------------------------------------------------------*/ /* int main(int argc, char **argv) */ /* Main program code */ /*--------------------------------------------------------*/ int main(int argc, char **argv) { int iRet = 0; l2_channel_t *pMyChannel = NULL; l2_handler_t *g_pFileHandler = &l2_handler_file; fprintf(stdout, "Trying file channel handler...\n"); pMyChannel = l2_channel_create(g_pFileHandler); if (pMyChannel == NULL) throw("Channel create failed!\n"); /* Parameters "path", "File path", "append", TRUE, "perm", 0xValue */ iRet = l2_channel_configure(pMyChannel, "path",\ "/u/ms/travail/l2/ding", "append", TRUE, "perm", 0x755); if (iRet != L2_OK) throw("Channel configure failed!\n"); iRet = l2_channel_open(pMyChannel); if (iRet != L2_OK) throw("Channel open failed!\n"); /* Need to subtract one to throw away null termination */ iRet = l2_channel_write(pMyChannel, SZ_LOGSTRING, sizeof(SZ_LOGSTRING) - 1); if (iRet != L2_OK) throw("Channel write failed!\n"); iRet = l2_channel_flush(pMyChannel); if (iRet != L2_OK) throw("Channel flush failed!\n"); iRet = l2_channel_close(pMyChannel); if (iRet != L2_OK) throw("Channel close failed!\n"); iRet = l2_channel_destroy(pMyChannel); if (iRet != L2_OK) throw("Channel destroy failed!\n"); fprintf(stdout, "Success, exiting...\n"); return 0; }