OpenCOBOL 1.1pre-rel
Classes | Defines | Enumerations | Functions | Variables
cobc.h File Reference
#include <stdio.h>
#include <libcob.h>
#include "lib/gettext.h"
#include "flag.def"
#include "warning.def"
#include "config.def"
Include dependency graph for cobc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cb_exception
struct  cb_text_list
struct  cb_replace_list
struct  local_filename
struct  filename
struct  noreserve

Defines

#define COB_NON_ALIGNED
#define ABORT()   cobc_abort(__FILE__,__LINE__)
#define CB_FORMAT_FIXED   0
#define CB_FORMAT_FREE   1
#define CB_EXCEPTION_NAME(id)   cb_exception_table[id].name
#define CB_EXCEPTION_CODE(id)   cb_exception_table[id].code
#define CB_EXCEPTION_ENABLE(id)   cb_exception_table[id].enable
#define CB_FLAG(var, name, doc)   extern int var;
#define CB_WARNDEF(var, name, wall, doc)   extern int var;
#define CB_CONFIG_ANY(type, var, name)   extern type var;
#define CB_CONFIG_INT(var, name)   extern int var;
#define CB_CONFIG_STRING(var, name)   extern const char *var;
#define CB_CONFIG_BOOLEAN(var, name)   extern int var;
#define CB_CONFIG_SUPPORT(var, name)   extern enum cb_support var;

Enumerations

enum  cb_assign_clause { CB_ASSIGN_COBOL2002, CB_ASSIGN_MF, CB_ASSIGN_IBM }
enum  cb_binary_byteorder { CB_BYTEORDER_NATIVE, CB_BYTEORDER_BIG_ENDIAN }
enum  cb_binary_size { CB_BINARY_SIZE_2_4_8, CB_BINARY_SIZE_1_2_4_8, CB_BINARY_SIZE_1__8 }
enum  cb_operation_type { CB_OPERATION_READ, CB_OPERATION_WRITE, CB_OPERATION_ASSIGN }
enum  cb_support {
  CB_OK, CB_WARNING, CB_ARCHAIC, CB_OBSOLETE,
  CB_SKIP, CB_IGNORE, CB_ERROR, CB_UNCONFORMABLE
}

Functions

struct cb_text_listcb_text_list_add (struct cb_text_list *list, const char *name)
void * cobc_malloc (const size_t size)
void * cobc_realloc (void *prevptr, const size_t size)
void cobc_abort (const char *filename, const int linenum)
size_t cobc_check_valid_name (char *name)
int cb_load_std (const char *name)
int cb_load_conf (const char *fname, const int check_nodef, const int prefix_dir)
int pplex (void)
int ppparse (void)
int ppopen (const char *name, struct cb_replace_list *replace_list)
int ppcopy (const char *name, const char *lib, struct cb_replace_list *replace_list)
void pp_set_replace_list (struct cb_replace_list *replace_list)
int yylex (void)
int yyparse (void)
void cb_warning (const char *fmt,...)
void cb_error (const char *fmt,...)
int cb_verify (const enum cb_support tag, const char *feature)

Variables

int cb_source_format
int cb_display_sign
struct cb_exception cb_exception_table []
int cb_id
int cb_attr_id
int cb_literal_id
int cb_field_id
int cb_storage_id
int cb_flag_main
int errorcount
int warningcount
int alt_ebcdic
int optimize_flag
int has_external
char * cb_oc_build_stamp
char * cb_source_file
int cb_source_line
const char * cob_config_dir
char * source_name
char * demangle_name
FILE * cb_storage_file
char * cb_storage_file_name
char ** cb_saveargv
int cb_saveargc
FILE * cb_listing_file
FILE * cb_depend_file
char * cb_depend_target
struct cb_text_listcb_depend_list
struct cb_text_listcb_include_list
struct cb_text_listcb_extension_list
struct cb_programcurrent_program
struct cb_statementcurrent_statement
struct cb_labelcurrent_section
struct cb_labelcurrent_paragraph
size_t functions_are_all
struct noreservenorestab
FILE * ppin
FILE * ppout
FILE * yyin
FILE * yyout
size_t sending_id
size_t suppress_warn

Define Documentation

#define ABORT ( )    cobc_abort(__FILE__,__LINE__)

Definition at line 37 of file cobc.h.

#define CB_CONFIG_ANY (   type,
  var,
  name 
)    extern type var;

Definition at line 198 of file cobc.h.

#define CB_CONFIG_BOOLEAN (   var,
  name 
)    extern int var;

Definition at line 201 of file cobc.h.

#define CB_CONFIG_INT (   var,
  name 
)    extern int var;

Definition at line 199 of file cobc.h.

#define CB_CONFIG_STRING (   var,
  name 
)    extern const char *var;

Definition at line 200 of file cobc.h.

#define CB_CONFIG_SUPPORT (   var,
  name 
)    extern enum cb_support var;

Definition at line 202 of file cobc.h.

#define CB_EXCEPTION_CODE (   id)    cb_exception_table[id].code

Definition at line 53 of file cobc.h.

#define CB_EXCEPTION_ENABLE (   id)    cb_exception_table[id].enable

Definition at line 54 of file cobc.h.

#define CB_EXCEPTION_NAME (   id)    cb_exception_table[id].name

Definition at line 52 of file cobc.h.

#define CB_FLAG (   var,
  name,
  doc 
)    extern int var;

Definition at line 57 of file cobc.h.

#define CB_FORMAT_FIXED   0

Definition at line 39 of file cobc.h.

#define CB_FORMAT_FREE   1

Definition at line 40 of file cobc.h.

#define CB_WARNDEF (   var,
  name,
  wall,
  doc 
)    extern int var;

Definition at line 62 of file cobc.h.

#define COB_NON_ALIGNED

Definition at line 30 of file cobc.h.


Enumeration Type Documentation

Enumerator:
CB_ASSIGN_COBOL2002 
CB_ASSIGN_MF 
CB_ASSIGN_IBM 

Definition at line 158 of file cobc.h.

                      {
        CB_ASSIGN_COBOL2002,            /* COBOL 2002 standard */
        CB_ASSIGN_MF,                   /* Micro Focus COBOL compatibility */
        CB_ASSIGN_IBM                   /* IBM COBOL compatibility */
};
Enumerator:
CB_BYTEORDER_NATIVE 
CB_BYTEORDER_BIG_ENDIAN 

Definition at line 164 of file cobc.h.

Enumerator:
CB_BINARY_SIZE_2_4_8 
CB_BINARY_SIZE_1_2_4_8 
CB_BINARY_SIZE_1__8 

Definition at line 169 of file cobc.h.

                    {
        CB_BINARY_SIZE_2_4_8,           /* 2,4,8 bytes */
        CB_BINARY_SIZE_1_2_4_8,         /* 1,2,4,8 bytes */
        CB_BINARY_SIZE_1__8             /* 1,2,3,4,5,6,7,8 bytes */
};
Enumerator:
CB_OPERATION_READ 
CB_OPERATION_WRITE 
CB_OPERATION_ASSIGN 

Definition at line 175 of file cobc.h.

enum cb_support
Enumerator:
CB_OK 
CB_WARNING 
CB_ARCHAIC 
CB_OBSOLETE 
CB_SKIP 
CB_IGNORE 
CB_ERROR 
CB_UNCONFORMABLE 

Definition at line 181 of file cobc.h.


Function Documentation

void cb_error ( const char *  fmt,
  ... 
)

Definition at line 85 of file error.c.

{
        va_list ap;

        va_start (ap, fmt);
        print_error (NULL, 0, "Error: ", fmt, ap);
        va_end (ap);

        errorcount++;

}

Here is the caller graph for this function:

int cb_load_conf ( const char *  fname,
const int  check_nodef,
const int  prefix_dir 
)

Definition at line 112 of file config.c.

{
        char                    *s;
        char                    *e;
        const char              *name;
        const char              *val;
        void                    *var;
        FILE                    *fp;
        char                    *nores;
        struct noreserve        *noresptr;
        int                     i;
        int                     j;
        int                     ret;
        int                     saveret;
        int                     line;
        char                    buff[COB_SMALL_BUFF];

        /* initialize the config table */
        if (check_nodef) {
                for (i = 0; config_table[i].name; i++) {
                        config_table[i].val = NULL;
                }
        }

        if (prefix_dir) {
                snprintf (buff, COB_SMALL_MAX, "%s/%s", cob_config_dir, fname);
                name = buff;
        } else {
                name = fname;
        }
        /* open the config file */
        fp = fopen (name, "r");
        if (fp == NULL) {
                perror (name);
                return -1;
        }

        /* read the config file */
        ret = 0;
        line = 0;
        while (fgets (buff, COB_SMALL_BUFF, fp)) {
                line++;

                /* skip comments */
                if (buff[0] == '#') {
                        continue;
                }

                /* skip blank lines */
                for (s = buff; *s; s++) {
                        if (isgraph (*s)) {
                                break;
                        }
                }
                if (!*s) {
                        continue;
                }

                /* get the tag */
                s = strpbrk (buff, " \t:=");
                if (!s) {
                        fprintf (stderr, "%s:%d: invalid line\n", fname, line);
                        ret = -1;
                        continue;
                }
                *s = 0;

                /* find the entry */
                for (i = 0; config_table[i].name; i++) {
                        if (strcmp (buff, config_table[i].name) == 0) {
                                break;
                        }
                }
                if (!config_table[i].name) {
                        fprintf (stderr, "%s:%d: unknown tag '%s'\n", fname, line, buff);
                        ret = -1;
                        continue;
                }

                /* get the value */
                for (s++; *s && strchr (" \t:=", *s); s++) {
                        ;
                }
                e = s + strlen (s) - 1;
                for (; e >= s && strchr (" \t\r\n", *e); e--) {
                        ;
                }
                e[1] = 0;
                config_table[i].val = s;

                /* set the value */
                name = config_table[i].name;
                var = config_table[i].var;
                val = config_table[i].val;
                switch (config_table[i].type) {
                case ANY:
                        if (strcmp (name, "assign-clause") == 0) {
                                if (strcmp (val, "cobol2002") == 0) {
                                        unsupported_value (fname, line, val);
                                        ret = -1;
                                } else if (strcmp (val, "mf") == 0) {
                                        cb_assign_clause = CB_ASSIGN_MF;
                                } else if (strcmp (val, "ibm") == 0) {
                                        cb_assign_clause = CB_ASSIGN_IBM;
                                } else {
                                        invalid_value (fname, line, name);
                                        ret = -1;
                                }
                        } else if (strcmp (name, "binary-size") == 0) {
                                if (strcmp (val, "2-4-8") == 0) {
                                        cb_binary_size = CB_BINARY_SIZE_2_4_8;
                                } else if (strcmp (val, "1-2-4-8") == 0) {
                                        cb_binary_size = CB_BINARY_SIZE_1_2_4_8;
                                } else if (strcmp (val, "1--8") == 0) {
                                        cb_binary_size = CB_BINARY_SIZE_1__8;
                                } else {
                                        invalid_value (fname, line, name);
                                        ret = -1;
                                }
                        } else if (strcmp (name, "binary-byteorder") == 0) {
                                if (strcmp (val, "native") == 0) {
                                        cb_binary_byteorder = CB_BYTEORDER_NATIVE;
                                } else if (strcmp (val, "big-endian") == 0) {
                                        cb_binary_byteorder = CB_BYTEORDER_BIG_ENDIAN;
                                } else {
                                        invalid_value (fname, line, name);
                                        ret = -1;
                                }
                        }
                        break;
                case INT:
                        for (j = 0; val[j]; j++) {
                                if (!isdigit (val[j])) {
                                        invalid_value (fname, line, name);
                                        ret = -1;
                                        break;
                                }
                        }
                        *((int *)var) = atoi (val);
                        break;
                case STRING:
                        val = read_string (val);

                        if (strcmp (name, "include") == 0) {
                                /* include another conf file */
                                saveret = ret;
                                if (cb_load_conf (val, 0, 1) != 0) {
                                        return -1;
                                }
                                ret = saveret;
                        } else if (strcmp (name, "not-reserved") == 0) {
                                nores = read_string (val);
                                noresptr = cobc_malloc (sizeof (struct noreserve));
                                noresptr->noresword = cobc_malloc (strlen (nores) + 1);
                                strcpy (noresptr->noresword, nores);
                                noresptr->next = norestab;
                                norestab = noresptr;
                        } else {
                                *((const char **)var) = val;
                        }
                        break;
                case BOOLEAN:
                        if (strcmp (val, "yes") == 0) {
                                *((int *)var) = 1;
                        } else if (strcmp (val, "no") == 0) {
                                *((int *)var) = 0;
                        } else {
                                invalid_value (fname, line, name);
                                ret = -1;
                        }
                        break;
                case SUPPORT:
                        if (strcmp (val, "ok") == 0) {
                                *((enum cb_support *)var) = CB_OK;
                        } else if (strcmp (val, "warning") == 0) {
                                *((enum cb_support *)var) = CB_WARNING;
                        } else if (strcmp (val, "archaic") == 0) {
                                *((enum cb_support *)var) = CB_ARCHAIC;
                        } else if (strcmp (val, "obsolete") == 0) {
                                *((enum cb_support *)var) = CB_OBSOLETE;
                        } else if (strcmp (val, "skip") == 0) {
                                *((enum cb_support *)var) = CB_SKIP;
                        } else if (strcmp (val, "ignore") == 0) {
                                *((enum cb_support *)var) = CB_IGNORE;
                        } else if (strcmp (val, "error") == 0) {
                                *((enum cb_support *)var) = CB_ERROR;
                        } else if (strcmp (val, "unconformable") == 0) {
                                *((enum cb_support *)var) = CB_UNCONFORMABLE;
                        } else {
                                invalid_value (fname, line, name);
                                ret = -1;
                        }
                        break;
                default:
                        fprintf (stderr, _("%s:%d: invalid type for '%s'\n"),
                                 fname, line, name);
                        ret = -1;
                        break;
                }
        }
        fclose (fp);

        /* checks for no definition */
        if (check_nodef) {
                for (i = 2; config_table[i].name; i++) {
                        if (config_table[i].val == NULL) {
                                fprintf (stderr, "%s: no definition of '%s'\n",
                                         fname, config_table[i].name);
                                ret = -1;
                        }
                }
        }

        return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int cb_load_std ( const char *  name)

Definition at line 106 of file config.c.

{
        return cb_load_conf (name, 1, 1);
}

Here is the call graph for this function:

struct cb_text_list* cb_text_list_add ( struct cb_text_list list,
const char *  name 
) [read]

Definition at line 355 of file cobc.c.

{
        struct cb_text_list *p;
        struct cb_text_list *l;

        p = cobc_malloc (sizeof (struct cb_text_list));
        p->text = strdup (text);
        p->next = NULL;
        if (!list) {
                return p;
        } else {
                for (l = list; l->next; l = l->next) { ; }
                l->next = p;
                return list;
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int cb_verify ( const enum cb_support  tag,
const char *  feature 
)

Definition at line 122 of file error.c.

{
        switch (tag) {
        case CB_OK:
                return 1;
        case CB_WARNING:
                return 1;
        case CB_ARCHAIC:
                if (cb_warn_archaic) {
                        cb_warning (_("%s is archaic in %s"), feature, cb_config_name);
                }
                return 1;
        case CB_OBSOLETE:
                if (cb_warn_obsolete) {
                        cb_warning (_("%s is obsolete in %s"), feature, cb_config_name);
                }
                return 1;
        case CB_SKIP:
                return 0;
        case CB_IGNORE:
                cb_warning (_("%s ignored"), feature);
                return 0;
        case CB_ERROR:
                return 0;
        case CB_UNCONFORMABLE:
                cb_error (_("%s does not conform to %s"), feature, cb_config_name);
                return 0;
        }
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_warning ( const char *  fmt,
  ... 
)

Definition at line 73 of file error.c.

{
        va_list ap;

        va_start (ap, fmt);
        print_error (NULL, 0, "Warning: ", fmt, ap);
        va_end (ap);

        warningcount++;
}

Here is the caller graph for this function:

void cobc_abort ( const char *  filename,
const int  linenum 
)

Definition at line 310 of file cobc.c.

{
        fprintf (stderr, "%s:%d: Internal compiler error\n", filename, linenum);
        (void)longjmp (cob_jmpbuf, 1);
}
size_t cobc_check_valid_name ( char *  name)

Definition at line 373 of file cobc.c.

{
        size_t  n;

        for (n = 0; n < COB_NUM_CSYNS; ++n) {
                if (!strcmp (name, cob_csyns[n])) {
                        return 1;
                }
        }
        return 0;
}

Here is the caller graph for this function:

void* cobc_malloc ( const size_t  size)

Definition at line 327 of file cobc.c.

{
        void *mptr;

        mptr = calloc (1, size);
        if (!mptr) {
                fprintf (stderr, "Cannot allocate %d bytes of memory - Aborting\n", (int)size);
                fflush (stderr);
                (void)longjmp (cob_jmpbuf, 1);
        }
        return mptr;
}

Here is the caller graph for this function:

void* cobc_realloc ( void *  prevptr,
const size_t  size 
)

Definition at line 341 of file cobc.c.

{
        void *mptr;

        mptr = realloc (prevptr, size);
        if (!mptr) {
                fprintf (stderr, "Cannot reallocate %d bytes of memory - Aborting\n", (int)size);
                fflush (stderr);
                (void)longjmp (cob_jmpbuf, 1);
        }
        return mptr;
}
void pp_set_replace_list ( struct cb_replace_list replace_list)
int ppcopy ( const char *  name,
const char *  lib,
struct cb_replace_list replace_list 
)
int pplex ( void  )
int ppopen ( const char *  name,
struct cb_replace_list replace_list 
)
int ppparse ( void  )
int yylex ( void  )
int yyparse ( void  )

Variable Documentation

Definition at line 121 of file cobc.c.

Definition at line 113 of file cobc.c.

Definition at line 134 of file cobc.c.

Definition at line 136 of file cobc.c.

Definition at line 135 of file cobc.c.

Definition at line 84 of file cobc.c.

Definition at line 138 of file cobc.c.

Definition at line 115 of file cobc.c.

Definition at line 117 of file cobc.c.

int cb_id

Definition at line 112 of file cobc.c.

Definition at line 137 of file cobc.c.

Definition at line 133 of file cobc.c.

Definition at line 114 of file cobc.c.

Definition at line 125 of file cobc.c.

Definition at line 140 of file cobc.c.

char** cb_saveargv

Definition at line 141 of file cobc.c.

Definition at line 124 of file cobc.c.

Definition at line 79 of file cobc.c.

Definition at line 128 of file cobc.c.

Definition at line 130 of file cobc.c.

Definition at line 131 of file cobc.c.

Definition at line 116 of file cobc.c.

const char* cob_config_dir

Definition at line 143 of file cobc.c.

Definition at line 986 of file parser.c.

Definition at line 983 of file parser.c.

Definition at line 985 of file parser.c.

Definition at line 984 of file parser.c.

Definition at line 127 of file cobc.c.

Definition at line 119 of file cobc.c.

Definition at line 987 of file parser.c.

Definition at line 138 of file codegen.c.

Definition at line 52 of file config.c.

Definition at line 122 of file cobc.c.

FILE* ppin
FILE* ppout
size_t sending_id

Definition at line 74 of file typeck.c.

char* source_name

Definition at line 126 of file cobc.c.

size_t suppress_warn

Definition at line 75 of file typeck.c.

Definition at line 120 of file cobc.c.

FILE* yyin
FILE* yyout
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines