Index of Functions: A B C D E F G H I J K L M N O P Q R S T U V W X
Index Page getcml_c

Table of contents

Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries

#### Procedure

       getcml_c ( Get the command line )

       void getcml_c ( SpiceInt     * argc,
                       SpiceChar  *** argv )

#### Abstract

       Store the contents of argv and argc for later access..

#### Required_Reading

       None.

#### Keywords

       UTILITY

#### Brief_I/O

       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       argc       O   The number of command line arguments.
       argv       O   The vector of command line arguments.

#### Detailed_Input

       None.

#### Detailed_Output

       argc        is the number of command line arguments.

       argv        is the vector of space delimited command line arguments.
                   Each entry entry contains one argument. argv[0] is the
                   command name.

#### Parameters

       None.

#### Exceptions

       1)  If getcml_c is called before putcml_c in any given program, an
           error is signaled by a routine in the call tree of this routine.

#### Files

       None.

#### Particulars

       This routine is a wrapper function for zzgetcml_c.c. getcml_c
       allows a user to access the argv and argc values from any program
       module.

#### Examples

       The numerical results shown for these examples may differ across
       platforms. The results depend on the SPICE kernels used as
       input, the compiler and supporting libraries, and the machine
       specific arithmetic implementation.

       1) The following code fragment demonstrates how getcml_c and
          putcml_c are used for allowing any program module to access
          the argv and argc values provided through the command line.

          #include <stdio.h>
          #include <stdlib.h>

          #include "SpiceUsr.h"

          void main( int argc, char *argv[] )
          {

             /.
             Store argv and argc for latter access.
             ./
             putcml_c (argc, argv );

             ..... other stuff .....
             .....             .....

          }

          void goop ()
          {
             ..... new module .....

             SpiceInt      argc;
             SpiceChar  ** argv;

             .....
             .....

             /.
             Now get the stored information.
             ./

             getcml_c ( &argc, &argv );

          }

       2) getcml_c and putcml_c could also be used to test the interaction
          of program modules with command line arguments, from a testing
          framework, i.e. without interacting with the program through
          command line. The following example demonstrates how.

          Example code begins here.

          /.
             Program getcml_ex2
          ./
          #include <stdio.h>
          #include "SpiceUsr.h"

          /.
          Declaration of the printme module.
          ./
          void printme( );

          int main( )
          {
             /.
             Local parameters.
             ./
             #define NVALS       4

             /.
             Local variables
             ./
             SpiceChar   * values[NVALS] = { "program", "argv1",
                                             "argv2",   "argv3" };

             /.
             Store nvals and values for latter access by another module.
             ./
             putcml_c ( NVALS, values );

             /.
             Run the module.
             ./
             printme( );

             return ( 0 );
          }

          /.
          printme module, which takes the nvals and values provided in
          the main block of the program, and prints them to the screen.
          ./
          void printme( )
          {
             /.
             Local variables.
             ./
             SpiceInt      argc;
             SpiceChar  ** argv;

             SpiceInt      i;

             /.
             Get the stored "command line" information.
             ./
             getcml_c ( &argc, &argv );

             /.
             Output the data.
             ./
             printf( "Number of command line arguments: %d\n\n", (int)argc );
             for ( i = 0; i < argc; i++ )
             {
                printf( "   Argument %d: %s\n", (int)i, argv[i] );
             }

          }

          When this program was executed on a Mac/Intel/cc/64-bit
          platform, the output was:

          Number of command line arguments: 4

             Argument 0: program
             Argument 1: argv1
             Argument 2: argv2
             Argument 3: argv3

#### Restrictions

       None.

#### Literature_References

       None.

#### Author_and_Institution

       J. Diaz del Rio     (ODC Space)
       E.D. Wright         (JPL)

#### Version

       -CSPICE Version 1.0.3, 05-AUG-2021 (JDR)

           Edited the header to comply with NAIF standard. Added
           complete code example.

           Improved -Exceptions section, adding the actual description of
           all possible issues detected by this routine.

       -CSPICE Version 1.0.2, 08-FEB-1998 (EDW)

           Routine rewritten to use private routine zzgetcml_c.c.

       -CSPICE Version 1.0.1, 14-JAN-1997 (EDW)

           Replaced a defined variable type for argv with a *** declaration.

       -CSPICE Version 1.0.0, 06-JAN-1997 (EDW)

#### Index_Entries

       store/retrieve argc argv

#### Link to routine getcml_c source file getcml_c.c

    Fri Dec 31 18:41:07 2021