OSSP CVS Repository

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

Check-in Number: 690
Date: 2001-Aug-17 21:23:51 (local)
2001-Aug-17 19:23:51 (UTC)
User:ms
Branch:
Comment: File used for individual channel testing, currently using file handler object

Submitted by: ms

Tickets:
Inspections:
Files:
ossp-pkg/l2/epreuve.c      added-> 1.1

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

*** /dev/null    Fri Mar 29 13:15:35 2024
--- -    Fri Mar 29 13:18:54 2024
***************
*** 0 ****
--- 1,59 ----
+ #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;
+ }

CVSTrac 2.0.1