HTML automatically generated with rman
Table of Contents

Name

nemo_main - preferred main entry point for NEMO C and C++ programs

Synopsis


 
#include <stdinc.h>
#include <getparam.h>
string defv[] = {
    "key=val\n       helpstring",
    ...
    "VERSION=x.y\n   mm-ddd-yy  AUTHOR",
    NULL,
};
string usage="Usage message ... ";
string cvsid="$Id$";    

void nemo_main(void)
{
    stropen(getparam("in"),"r");
    stropen(getparam("out"),"w");
    ...
}

Description

nemo_main can be called to free the programmer of calling the standard startup and shutdown code which deals with the user interface. This also allows the future NEMO libraries to have a different setup for startup and/or shutdown of a single task.

Instead of starting a program with main(argc,argv) a NEMO program should be started with nemo_main(), but see LIMITATIONS below.

The code for nemo_main looks something like:

   #include <stdinc.h>
   #include <getparam.h>
   extern string defv[];           /* defv MUST be defined in user program
! */
   void main(argc,argv)
   int argc;                               /* number of arguments + 1 */
   char *argv[];                           /* pointer to arguments */
   {
      if(argv[argc] != NULL)
         warning("Your C compiler seems to have an old-style (short) argv[]");
      initparam(argv,defv);               /* start  */
      nemo_main();                        /* call program */
      finiparam();                        /* end */
      exit(0);                            /* return normal status to shell
*/
   }

Limitations

The pointer to the array of key=value default keywords (see getparam(3NEMO) ) MUST be called by name defv as shown in the SYNOPSIS section above, since nemo_main defines this as extern string defv[]. Stubbed code exist within the NEMO library in defv.c and usage.c, to ensure that programs will still link. They will however have no controlled access to the commandline arguments.

See Also

getparam(3NEMO)

Files


~/src/kernel/misc    nemomain.c nemomain.cc    c and c++ versions
~/src/kernel/io      defv.c usage.c        stubs for missing extern

Author

Peter Teuben

Update History


29-jun-89    created      PJT
28-nov-94    doc             PJT
17-mar-04    void        PJT


Table of Contents