OpenCOBOL 1.1pre-rel
Functions
cobcrun.c File Reference
#include "config.h"
#include "defaults.h"
#include <stdio.h>
#include <string.h>
#include <libcob.h>
#include <tarstamp.h>
Include dependency graph for cobcrun.c:

Go to the source code of this file.

Functions

static void print_version (void)
static void print_usage (void)
int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 63 of file cobcrun.c.

{
        union {
                int     (*func)();
                void    *func_void;
        } unifunc;

        if (argc <= 1) {
                print_usage ();
                return 1;
        }
        /* Quick check without getopt */
        if (!strncmp (argv[1], "--version", 10) ||
            !strncmp (argv[1], "-V", 4)) {
                print_version ();
                return 0;
        }
        if (!strncmp (argv[1], "--help", 10) ||
            !strncmp (argv[1], "-h", 4)) {
                print_usage ();
                return 0;
        }
        if (strlen (argv[1]) > 31) {
                fprintf (stderr, "Invalid PROGRAM name\n");
                return 1;
        }
        cob_init (argc - 1, &argv[1]);
        unifunc.func_void = cob_resolve (argv[1]);
        if (unifunc.func_void == NULL) {
                cob_call_error ();
        }
        cob_stop_run ( unifunc.func() );
}

Here is the call graph for this function:

static void print_usage ( void  ) [static]

Definition at line 53 of file cobcrun.c.

{
        printf ("Usage: cobcrun PROGRAM [param ...]\n");
        printf ("or   : cobcrun --help (-h)\n");
        printf ("       Print this help\n");
        printf ("or   : cobcrun --version (-V)\n");
        printf ("       Print version information\n");
}

Here is the caller graph for this function:

static void print_version ( void  ) [static]

Definition at line 29 of file cobcrun.c.

{
        int     year;
        int     day;
        char    buff[64];
        char    month[64];

        memset (buff, 0, sizeof(buff));
        memset (month, 0, sizeof(month));
        day = 0;
        year = 0;
        sscanf (__DATE__, "%s %d %d", month, &day, &year);
        if (day && year) {
                sprintf (buff, "%s %2.2d %4.4d %s", month, day, year, __TIME__);
        } else {
                sprintf (buff, "%s %s", __DATE__, __TIME__);
        }
        printf ("cobcrun (%s) %s.%d\n",
                PACKAGE_NAME, PACKAGE_VERSION, PATCH_LEVEL);
        puts ("Copyright (C) 2004-2009 Roger While");
        printf ("Built    %s\nPackaged %s\n", buff, octardate);
}

Here is the caller graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines