home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / portmngr / dignstcs.c next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  3.1 KB  |  93 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/drapeau/PortManager/RCS/Diagnostics.c,v 0.11 91/09/18 13:07:41 drapeau Exp Locker: drapeau $ */
  25. /* $Log:    Diagnostics.c,v $
  26.  * Revision 0.11  91/09/18  13:07:41  drapeau
  27.  * No changes.
  28.  * 
  29.  * Revision 0.10  91/09/09  18:24:33  drapeau
  30.  * First version of the diagnostics routines, used by all other modules in this
  31.  * program.
  32.  *  */
  33.  
  34. static char    portMgrDiagRcsid[] = "$Header: /Source/Media/drapeau/PortManager/RCS/Diagnostics.c,v 0.11 91/09/18 13:07:41 drapeau Exp Locker: drapeau $";
  35.  
  36. #include <stdio.h>
  37. #include <getopt.h>
  38.  
  39. static int    diagnosticsOn = 0;                    /* Flag to determine whether to print diagnostic messages */
  40. char        diagMessage[1024];                    /* Space in which to print a diagnostic message */
  41.  
  42. void PrintDiagnostic(char* diagMessage)
  43. {
  44.   if (diagnosticsOn != 0)
  45.     printf("%s", diagMessage);
  46.   return;
  47. }                                    /* end function PrintDiagnostic */
  48.  
  49. void EnableDiagnostics()
  50. {
  51.   diagnosticsOn = 1;
  52.   return;
  53. }                                    /* end function EnableDiagnostics */
  54.  
  55.  
  56. /********************************************************************
  57.  *    GetCommandLineOptions
  58.  *
  59.  *
  60.  *    This function parses the command line and retrieves all the known
  61.  *    options and their arguments.  The only option currently recognized by
  62.  *    this function is "-diagnostics" (also known as "-d").
  63.  */
  64.  
  65. void GetCommandLineOptions(int argc, char** argv)
  66. {
  67.   int            optionChar;  
  68.   int            optionIndex = 0;
  69.   static struct option    longOptions[] =
  70.   {
  71.     {"diagnostics", 0, 0, 'd'},
  72.     {0, 0, 0, 0}
  73.   };
  74.   
  75.   while (1)                                /* Start parsing all known options */
  76.   {
  77.     optionChar = getopt_long_only (argc, argv, "d:",
  78.                    longOptions, &optionIndex);
  79.     if (optionChar == EOF)                        /* Done with all known options */
  80.     {
  81.       break;
  82.     }
  83.     switch (optionChar)
  84.     {
  85.      case 'd':                                /* Turn on diagnostic messages if asked for */
  86.       EnableDiagnostics();
  87.       break;
  88.      default:
  89.       break;
  90.     }                                    /* end switch */
  91.   }                                    /* end while */
  92. }                                    /* end function GetCommandLineOptions */
  93.