OSSP CVS Repository

ossp - Check-in [712]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 712
Date: 2001-Aug-20 19:17:16 (local)
2001-Aug-20 17:17:16 (UTC)
User:ms
Branch:
Comment: Test file for individual channel testing
Tickets:
Inspections:
Files:
ossp-pkg/l2/l2_epreuve.c      added-> 1.1

ossp-pkg/l2/l2_epreuve.c -> 1.1

*** /dev/null    Thu Apr 25 06:08:37 2024
--- -    Thu Apr 25 06:09:21 2024
***************
*** 0 ****
--- 1,95 ----
+ /*
+ **  L2 - OSSP Logging Library
+ **  Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+ **  Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ **
+ **  This file is part of OSSP L2, a flexible logging library which
+ **  can be found at http://www.ossp.org/pkg/l2/. 
+ **
+ **  Permission to use, copy, modify, and distribute this software for
+ **  any purpose with or without fee is hereby granted, provided that
+ **  the above copyright notice and this permission notice appear in all
+ **  copies.
+ **  
+ **  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ **  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ **  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ **  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ **  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ **  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ **  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ **  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ **  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ **  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ **  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ **  SUCH DAMAGE.
+ **
+ **  l2_epreuve.c: channel-level test code
+ **
+ */
+     
+ #include "l2.h"
+ #define SZ_LOGSTRING "String LogTest c'est deja la.\n"
+ 
+ /*--------------------------------------------------------*/
+ /* void throwup(char *pszError)                           */
+ /* Quick exception kludge                                 */
+ /*--------------------------------------------------------*/
+ void throwup(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;
+ 
+     if (argc < 2)
+     {
+         fprintf(stdout, "Usage: %s filepath\n", *argv);
+         exit(1);
+     }
+ 
+     fprintf(stdout, "Trying file channel handler...\n");
+ 
+     pMyChannel = l2_channel_create(g_pFileHandler);
+     if (pMyChannel == NULL)
+         throwup("Channel create failed!\n");
+ 
+     /* Params "path", <File path>, "append", <TRUE/FALSE>, "perm", <0xValue>, */
+     iRet = l2_channel_configure(pMyChannel, "path", argv[1],\
+         "append", TRUE, "perm", 0x755);
+     if (iRet != L2_OK)
+         throwup("Channel configure failed!\n");
+ 
+     iRet = l2_channel_open(pMyChannel);
+     if (iRet != L2_OK)
+         throwup("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)
+         throwup("Channel write failed!\n");
+ 
+     iRet = l2_channel_flush(pMyChannel);
+     if (iRet != L2_OK)
+         throwup("Channel flush failed!\n");
+ 
+     iRet = l2_channel_close(pMyChannel);
+     if (iRet != L2_OK)
+         throwup("Channel close failed!\n");
+ 
+     iRet = l2_channel_destroy(pMyChannel);
+     if (iRet != L2_OK)
+         throwup("Channel destroy failed!\n");
+ 
+     fprintf(stdout, "Success, exiting...\n");
+     return 0;
+ }

CVSTrac 2.0.1