reporter.c

Go to the documentation of this file.
00001 /****************************************************************************/
00002 /*                                                                          */
00003 /*  This file is part of QSopt_ex.                                          */
00004 /*                                                                          */
00005 /*  (c) Copyright 2006 by David Applegate, William Cook, Sanjeeb Dash,      */
00006 /*  and Daniel Espinoza                                                     */
00007 /*                                                                          */
00008 /*  Sanjeeb Dash ownership of copyright in QSopt_ex is derived from his     */
00009 /*  copyright in QSopt.                                                     */
00010 /*                                                                          */
00011 /*  This code may be used under the terms of the GNU General Public License */
00012 /*  (Version 2.1 or later) as published by the Free Software Foundation.    */
00013 /*                                                                          */
00014 /*  Alternatively, use is granted for research purposes only.               */
00015 /*                                                                          */
00016 /*  It is your choice of which of these two licenses you are operating      */
00017 /*  under.                                                                  */
00018 /*                                                                          */
00019 /*  We make no guarantees about the correctness or usefulness of this code. */
00020 /*                                                                          */
00021 /****************************************************************************/
00022 
00023 /* RCS_INFO = "$Id: reporter.c,v 1.1 2003/11/05 16:49:52 meven Exp $"; */
00024 
00025 #include "config.h"
00026 #include <stdio.h>
00027 #include "iqsutil.h"
00028 #include "reporter.h"
00029 
00030 int ILL_fprintf (
00031   void *dest,
00032   const char *s)
00033 {
00034   if (s != NULL)
00035     return fprintf ((FILE *) dest, s);
00036   return 0;
00037 }
00038 
00039 void ILLstring_reporter_init (
00040   qsstring_reporter * reporter,
00041   qsreport_string_fct fct,
00042   void *dest)
00043 {
00044   int rval = 0;
00045 
00046   ILL_FAILfalse (reporter != NULL, "Must get non NULL reporter");
00047   if (reporter != NULL)
00048   {
00049     reporter->report_fct = fct;
00050     reporter->dest = dest;
00051   }
00052 CLEANUP:
00053   return;
00054 }
00055 
00056 void ILLstring_reporter_copy (
00057   qsstring_reporter * dest,
00058   qsstring_reporter * src)
00059 {
00060   *dest = *src;
00061 }
00062 
00063 
00064 #ifdef REPORTER_MAIN
00065 static int string_reporter_main (
00066   int ac,
00067   char **av)
00068 {
00069   int i = 0;
00070   qsstring_reporter reporter;
00071 
00072   ILLstring_reporter_init (&reporter, ILL_fprintf, stdout);
00073   for (i = 0; i < ac; i++)
00074   {
00075     (void) ILLstring_report (av[i], &reporter);
00076     (void) ILLstring_report ("\n", &reporter);
00077   }
00078   (void) ILLstring_report (NULL, &reporter);
00079 
00080   return 0;
00081 }
00082 
00083 int main (
00084   int ac,
00085   char **av)
00086 {
00087   return string_reporter_main (ac, av);
00088 }
00089 #endif

Generated on Thu Mar 29 09:32:33 2012 for QSopt_ex by  doxygen 1.4.7