OpenCOBOL 1.1pre-rel
Classes | Defines | Functions | Variables
fileio.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <db.h>
#include "common.h"
#include "coblocal.h"
#include "move.h"
#include "numeric.h"
#include "fileio.h"
#include "byteswap.h"
Include dependency graph for fileio.c:

Go to the source code of this file.

Classes

struct  cobitem
struct  memory_struct
struct  file_struct
struct  cobsort
struct  file_list
struct  indexed_file

Defines

#define _LFS64_LARGEFILE   1
#define _LFS64_STDIO   1
#define _FILE_OFFSET_BITS   64
#define _LARGEFILE64_SOURCE   1
#define SEEK_INIT(f)   fseek ((FILE *)f->file, (off_t)0, SEEK_CUR)
#define O_BINARY   0
#define O_LARGEFILE   0
#define INITIAL_FLAGS   0
#define COBSORTEND   1
#define COBSORTABORT   2
#define COBSORTFILEERR   3
#define COBSORTNOTOPEN   4
#define RETURN_STATUS(x)   do { save_status (f, x, fnstatus); return; } while (0)
#define NUM_PREFIX   sizeof(prefix) / sizeof(char *)
#define DB_PUT(db, flags)   db->put (db, NULL, &p->key, &p->data, flags)
#define DB_GET(db, flags)   db->get (db, NULL, &p->key, &p->data, flags)
#define DB_SEQ(db, flags)   db->c_get (db, &p->key, &p->data, flags)
#define DB_DEL(db, key, flags)   db->del (db, NULL, key, flags)
#define DB_CLOSE(db)   db->close (db, 0)
#define DB_SYNC(db)   db->sync (db, 0)
#define cob_dbtsize_t   u_int32_t
#define DBT_SET(key, fld)

Functions

void cob_unlock_file (cob_file *f, cob_field *fnstatus)
void cob_open (cob_file *f, const int mode, const int sharing, cob_field *fnstatus)
void cob_close (cob_file *f, const int opt, cob_field *fnstatus)
void cob_start (cob_file *f, const int cond, cob_field *key, cob_field *fnstatus)
void cob_read (cob_file *f, cob_field *key, cob_field *fnstatus, int read_opts)
void cob_write (cob_file *f, cob_field *rec, const int opt, cob_field *fnstatus)
void cob_rewrite (cob_file *f, cob_field *rec, const int opt, cob_field *fnstatus)
void cob_delete (cob_file *f, cob_field *fnstatus)
void cob_commit (void)
void cob_rollback (void)
void cob_default_error_handle (void)
void cob_init_fileio (void)
void cob_exit_fileio (void)
int CBL_OPEN_FILE (unsigned char *file_name, unsigned char *file_access, unsigned char *file_lock, unsigned char *file_dev, unsigned char *file_handle)
int CBL_CREATE_FILE (unsigned char *file_name, unsigned char *file_access, unsigned char *file_lock, unsigned char *file_dev, unsigned char *file_handle)
int CBL_READ_FILE (unsigned char *file_handle, unsigned char *file_offset, unsigned char *file_len, unsigned char *flags, unsigned char *buf)
int CBL_WRITE_FILE (unsigned char *file_handle, unsigned char *file_offset, unsigned char *file_len, unsigned char *flags, unsigned char *buf)
int CBL_CLOSE_FILE (unsigned char *file_handle)
int CBL_FLUSH_FILE (unsigned char *file_handle)
int CBL_DELETE_FILE (unsigned char *file_name)
int CBL_COPY_FILE (unsigned char *fname1, unsigned char *fname2)
int CBL_CHECK_FILE_EXIST (unsigned char *file_name, unsigned char *file_info)
int CBL_RENAME_FILE (unsigned char *fname1, unsigned char *fname2)
int CBL_GET_CURRENT_DIR (const int flags, const int dir_length, unsigned char *dir)
int CBL_CREATE_DIR (unsigned char *dir)
int CBL_CHANGE_DIR (unsigned char *dir)
int CBL_DELETE_DIR (unsigned char *dir)
int cob_acuw_mkdir (unsigned char *dir)
int cob_acuw_chdir (unsigned char *dir, unsigned char *status)
int cob_acuw_copyfile (unsigned char *fname1, unsigned char *fname2, unsigned char *file_type)
int cob_acuw_file_info (unsigned char *file_name, unsigned char *file_info)
int cob_acuw_file_delete (unsigned char *file_name, unsigned char *file_type)
void cob_file_sort_using (cob_file *sort_file, cob_file *data_file)
void cob_file_sort_giving (cob_file *sort_file, const size_t varcnt,...)
void cob_file_sort_init (cob_file *f, const int nkeys, const unsigned char *collating_sequence, void *sort_return, cob_field *fnstatus)
void cob_file_sort_init_key (cob_file *f, const int flag, cob_field *field, size_t offset)
void cob_file_sort_close (cob_file *f)
void cob_file_release (cob_file *f)
void cob_file_return (cob_file *f)

Variables

cob_filecob_error_file

Define Documentation

#define _FILE_OFFSET_BITS   64

Definition at line 25 of file fileio.c.

#define _LARGEFILE64_SOURCE   1

Definition at line 26 of file fileio.c.

#define _LFS64_LARGEFILE   1

Definition at line 23 of file fileio.c.

#define _LFS64_STDIO   1

Definition at line 24 of file fileio.c.

#define cob_dbtsize_t   u_int32_t

Definition at line 288 of file fileio.c.

#define COBSORTABORT   2

Definition at line 154 of file fileio.c.

#define COBSORTEND   1

Definition at line 153 of file fileio.c.

#define COBSORTFILEERR   3

Definition at line 155 of file fileio.c.

#define COBSORTNOTOPEN   4

Definition at line 156 of file fileio.c.

#define DB_CLOSE (   db)    db->close (db, 0)

Definition at line 286 of file fileio.c.

#define DB_DEL (   db,
  key,
  flags 
)    db->del (db, NULL, key, flags)

Definition at line 285 of file fileio.c.

#define DB_GET (   db,
  flags 
)    db->get (db, NULL, &p->key, &p->data, flags)

Definition at line 283 of file fileio.c.

#define DB_PUT (   db,
  flags 
)    db->put (db, NULL, &p->key, &p->data, flags)

Definition at line 282 of file fileio.c.

#define DB_SEQ (   db,
  flags 
)    db->c_get (db, &p->key, &p->data, flags)

Definition at line 284 of file fileio.c.

#define DB_SYNC (   db)    db->sync (db, 0)

Definition at line 287 of file fileio.c.

#define DBT_SET (   key,
  fld 
)
Value:
key.data = fld->data;                           \
  key.size = (cob_dbtsize_t) fld->size

Definition at line 303 of file fileio.c.

#define INITIAL_FLAGS   0

Definition at line 148 of file fileio.c.

#define NUM_PREFIX   sizeof(prefix) / sizeof(char *)

Definition at line 250 of file fileio.c.

#define O_BINARY   0

Definition at line 138 of file fileio.c.

#define O_LARGEFILE   0

Definition at line 142 of file fileio.c.

#define RETURN_STATUS (   x)    do { save_status (f, x, fnstatus); return; } while (0)

Definition at line 234 of file fileio.c.

#define SEEK_INIT (   f)    fseek ((FILE *)f->file, (off_t)0, SEEK_CUR)

Definition at line 132 of file fileio.c.


Function Documentation

int CBL_CHANGE_DIR ( unsigned char *  dir)

Definition at line 4857 of file fileio.c.

{
        char    *fn;
        int     ret;

        COB_CHK_PARMS (CBL_CHANGE_DIR, 1);

        if (!cob_current_module->cob_procedure_parameters[0]) {
                return -1;
        }
        fn = cob_str_from_fld (cob_current_module->cob_procedure_parameters[0]);
        ret = chdir (fn);
        free (fn);
        if (ret) {
                return 128;
        }
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_CHECK_FILE_EXIST ( unsigned char *  file_name,
unsigned char *  file_info 
)

Definition at line 4722 of file fileio.c.

{
        char            *fn;
        struct tm       *tm;
        long long       sz;
        struct stat     st;
        short           y;
        char            d, m, hh, mm, ss;

        COB_CHK_PARMS (CBL_CHECK_FILE_EXIST, 2);

        if (!cob_current_module->cob_procedure_parameters[0]) {
                return -1;
        }
        fn = cob_str_from_fld (cob_current_module->cob_procedure_parameters[0]);
        if (stat (fn, &st) < 0) {
                free (fn);
                return 35;
        }
        free (fn);
        sz = st.st_size;
        tm = localtime (&st.st_mtime);
        d = (char) tm->tm_mday;
        m = (char) tm->tm_mon + 1;
        y = tm->tm_year + 1900;
        hh = (char) tm->tm_hour;
        mm = (char) tm->tm_min;
        ss = (char) tm->tm_sec;

#ifndef WORDS_BIGENDIAN
        sz = COB_BSWAP_64 (sz);
        y = COB_BSWAP_16 (y);
#endif
        memcpy (file_info, &sz, 8);
        file_info[8] = d;
        file_info[9] = m;
        memcpy (file_info+10, &y, 2);
        file_info[12] = hh;
        file_info[13] = mm;
        file_info[14] = ss;
        file_info[15] = 0;
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_CLOSE_FILE ( unsigned char *  file_handle)

Definition at line 4631 of file fileio.c.

{
        int     fd;

        COB_CHK_PARMS (CBL_CLOSE_FILE, 1);

        memcpy (&fd, file_handle, 4);
        return close (fd);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_COPY_FILE ( unsigned char *  fname1,
unsigned char *  fname2 
)

Definition at line 4670 of file fileio.c.

{
        char    *fn1;
        char    *fn2;
#ifdef  O_BINARY
        int     flag = O_BINARY;
#else
        int     flag = 0;
#endif
        int     ret;
        int     i;
        int     fd1, fd2;

        COB_CHK_PARMS (CBL_COPY_FILE, 2);

        if (!cob_current_module->cob_procedure_parameters[0]) {
                return -1;
        }
        if (!cob_current_module->cob_procedure_parameters[1]) {
                return -1;
        }
        fn1 = cob_str_from_fld (cob_current_module->cob_procedure_parameters[0]);
        flag |= O_RDONLY;
        fd1 = open (fn1, flag, 0);
        if (fd1 < 0) {
                free (fn1);
                return -1;
        }
        free (fn1);
        fn2 = cob_str_from_fld (cob_current_module->cob_procedure_parameters[1]);
        flag &= ~O_RDONLY;
        flag |= O_CREAT | O_TRUNC | O_WRONLY;
        fd2 = open (fn2, flag, 0660);
        if (fd2 < 0) {
                close (fd1);
                free (fn2);
                return -1;
        }
        free (fn2);
        ret = 0;
        while ((i = read (fd1, fn1, sizeof(fn1))) > 0) {
                if (write (fd2, fn1, (size_t)i) < 0) {
                        ret = -1;
                        break;
                }
        }
        close (fd1);
        close (fd2);
        return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_CREATE_DIR ( unsigned char *  dir)

Definition at line 4833 of file fileio.c.

{
        char    *fn;
        int     ret;

        COB_CHK_PARMS (CBL_CREATE_DIR, 1);

        if (!cob_current_module->cob_procedure_parameters[0]) {
                return -1;
        }
        fn = cob_str_from_fld (cob_current_module->cob_procedure_parameters[0]);
#ifdef  _WIN32
        ret = mkdir (fn);
#else
        ret = mkdir (fn, 0770);
#endif
        free (fn);
        if (ret) {
                return 128;
        }
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_CREATE_FILE ( unsigned char *  file_name,
unsigned char *  file_access,
unsigned char *  file_lock,
unsigned char *  file_dev,
unsigned char *  file_handle 
)

Definition at line 4548 of file fileio.c.

{
        COB_CHK_PARMS (CBL_CREATE_FILE, 5);

        return open_cbl_file (file_name, file_access, file_handle, O_CREAT | O_TRUNC);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_DELETE_DIR ( unsigned char *  dir)

Definition at line 4877 of file fileio.c.

{
        char    *fn;
        int     ret;

        COB_CHK_PARMS (CBL_DELETE_DIR, 1);

        if (!cob_current_module->cob_procedure_parameters[0]) {
                return -1;
        }
        fn = cob_str_from_fld (cob_current_module->cob_procedure_parameters[0]);
        ret = rmdir (fn);
        free (fn);
        if (ret) {
                return 128;
        }
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_DELETE_FILE ( unsigned char *  file_name)

Definition at line 4650 of file fileio.c.

{
        char    *fn;
        int     ret;

        COB_CHK_PARMS (CBL_DELETE_FILE, 1);

        if (!cob_current_module->cob_procedure_parameters[0]) {
                return -1;
        }
        fn = cob_str_from_fld (cob_current_module->cob_procedure_parameters[0]);
        ret = unlink (fn);
        free (fn);
        if (ret) {
                return 128;
        }
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_FLUSH_FILE ( unsigned char *  file_handle)

Definition at line 4642 of file fileio.c.

{
        COB_CHK_PARMS (CBL_FLUSH_FILE, 1);

        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_GET_CURRENT_DIR ( const int  flags,
const int  dir_length,
unsigned char *  dir 
)

Definition at line 4793 of file fileio.c.

{
        char    *dirname;
        int     dir_size;
        int     has_space;

        COB_CHK_PARMS (CBL_GET_CURRENT_DIR, 3);

        if (dir_length < 1) {
                return 128;
        }
        if (flags) {
                return 129;
        }
        memset (dir, ' ', (size_t)dir_length);
        dirname = getcwd (NULL, 0);
        if (dirname == NULL) {
                return 128;
        }
        dir_size = (int) strlen (dirname);
        has_space = 0;
        if (strchr (dirname, ' ')) {
                has_space = 2;
        }
        if (dir_size + has_space > dir_length) {
                free (dirname);
                return 128;
        }
        if (has_space) {
                *dir = '"';
                memcpy (&dir[1], dirname, (size_t)dir_size);
                dir[dir_size + 1] = '"';
        } else {
                memcpy (dir, dirname, (size_t)dir_size);
        }
        free (dirname);
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_OPEN_FILE ( unsigned char *  file_name,
unsigned char *  file_access,
unsigned char *  file_lock,
unsigned char *  file_dev,
unsigned char *  file_handle 
)

Definition at line 4538 of file fileio.c.

{
        COB_CHK_PARMS (CBL_OPEN_FILE, 5);

        return open_cbl_file (file_name, file_access, file_handle, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_READ_FILE ( unsigned char *  file_handle,
unsigned char *  file_offset,
unsigned char *  file_len,
unsigned char *  flags,
unsigned char *  buf 
)

Definition at line 4558 of file fileio.c.

{
        long long       off;
        int             fd;
        int             len;
        int             rc = 0;
        struct stat     st;

        COB_CHK_PARMS (CBL_READ_FILE, 5);

        memcpy (&fd, file_handle, 4);
        memcpy (&off, file_offset, 8);
        memcpy (&len, file_len, 4);
#ifndef WORDS_BIGENDIAN
        off = COB_BSWAP_64 (off);
        len = COB_BSWAP_32 (len);
#endif
        if (lseek (fd, (off_t)off, SEEK_SET) < 0) {
                return -1;
        }
        if (len > 0) {
                rc = read (fd, buf, (size_t)len);
                if (rc < 0) {
                        rc = -1;
                } else if (rc == 0) {
                        rc = 10;
                } else {
                        rc = 0;
                }
        }
        if ((*flags & 0x80) != 0) {
                if (fstat (fd, &st) < 0) {
                        return -1;
                }
                off = st.st_size;
#ifndef WORDS_BIGENDIAN
                off = COB_BSWAP_64 (off);
#endif
                memcpy (file_offset, &off, 8);
        }
        return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_RENAME_FILE ( unsigned char *  fname1,
unsigned char *  fname2 
)

Definition at line 4767 of file fileio.c.

{
        char    *fn1;
        char    *fn2;
        int     ret;

        COB_CHK_PARMS (CBL_RENAME_FILE, 2);

        if (!cob_current_module->cob_procedure_parameters[0]) {
                return -1;
        }
        if (!cob_current_module->cob_procedure_parameters[1]) {
                return -1;
        }
        fn1 = cob_str_from_fld (cob_current_module->cob_procedure_parameters[0]);
        fn2 = cob_str_from_fld (cob_current_module->cob_procedure_parameters[1]);
        ret = rename (fn1, fn2);
        free (fn1);
        free (fn2);
        if (ret) {
                return 128;
        }
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CBL_WRITE_FILE ( unsigned char *  file_handle,
unsigned char *  file_offset,
unsigned char *  file_len,
unsigned char *  flags,
unsigned char *  buf 
)

Definition at line 4603 of file fileio.c.

{
        long long       off;
        int             fd;
        int             len;
        int             rc;

        COB_CHK_PARMS (CBL_WRITE_FILE, 5);

        memcpy (&fd, file_handle, 4);
        memcpy (&off, file_offset, 8);
        memcpy (&len, file_len, 4);
#ifndef WORDS_BIGENDIAN
        off = COB_BSWAP_64 (off);
        len = COB_BSWAP_32 (len);
#endif
        if (lseek (fd, (off_t)off, SEEK_SET) < 0) {
                return -1;
        }
        rc = write (fd, buf, (size_t)len);
        if (rc < 0) {
                return 30;
        }
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int cob_acuw_chdir ( unsigned char *  dir,
unsigned char *  status 
)

Definition at line 4911 of file fileio.c.

{
        int             ret;

        COB_CHK_PARMS (C$CHDIR, 2);

        ret = CBL_CHANGE_DIR (dir);
        if (ret < 0) {
                ret = 128;
        }
        cob_set_int (cob_current_module->cob_procedure_parameters[1], ret);
        return ret;
}

Here is the call graph for this function:

int cob_acuw_copyfile ( unsigned char *  fname1,
unsigned char *  fname2,
unsigned char *  file_type 
)

Definition at line 4926 of file fileio.c.

{
        int             ret = 128;

        /* RXW - Type is not yet evaluated */

        COB_CHK_PARMS (C$COPY, 3);

        if (cob_call_params < 3) {
                return 128;
        }
        ret = CBL_COPY_FILE (fname1, fname2);
        if (ret < 0) {
                ret = 128;
        }
        return ret;
}

Here is the call graph for this function:

int cob_acuw_file_delete ( unsigned char *  file_name,
unsigned char *  file_type 
)

Definition at line 4993 of file fileio.c.

{
        int     ret;

        /* RXW - Type is not yet evaluated */
        COB_CHK_PARMS (C$DELETE, 2);

        if (cob_call_params < 2 || !cob_current_module->cob_procedure_parameters[0]) {
                return 128;
        }
        ret = CBL_DELETE_FILE (file_name);
        if (ret < 0) {
                ret = 128;
        }
        return ret;
}

Here is the call graph for this function:

int cob_acuw_file_info ( unsigned char *  file_name,
unsigned char *  file_info 
)

Definition at line 4945 of file fileio.c.

{
        char                    *fn;
        struct tm               *tm;
        unsigned long long      sz;
        unsigned int            dt;
        short                   y;
        short                   d, m, hh, mm, ss;
        struct stat             st;

        COB_CHK_PARMS (C$FILEINFO, 2);

        if (cob_call_params < 2 || !cob_current_module->cob_procedure_parameters[0]) {
                return 128;
        }
        fn = cob_str_from_fld (cob_current_module->cob_procedure_parameters[0]);
        if (stat (fn, &st) < 0) {
                free (fn);
                return 35;
        }
        free (fn);
        sz = st.st_size;
        tm = localtime (&st.st_mtime);
        d = tm->tm_mday;
        m = tm->tm_mon + 1;
        y = tm->tm_year + 1900;
        hh = tm->tm_hour;
        mm = tm->tm_min;
        ss = tm->tm_sec;

#ifndef WORDS_BIGENDIAN
        sz = COB_BSWAP_64 (sz);
#endif
        memcpy (file_info, &sz, 8);
        dt = (y * 10000) + (m * 100) + d;
#ifndef WORDS_BIGENDIAN
        dt = COB_BSWAP_32 (dt);
#endif
        memcpy (file_info + 8, &dt, 4);
        dt = (hh * 1000000) + (mm * 10000) + (ss * 100);
#ifndef WORDS_BIGENDIAN
        dt = COB_BSWAP_32 (dt);
#endif
        memcpy (file_info + 12, &dt, 4);
        return 0;
}
int cob_acuw_mkdir ( unsigned char *  dir)

Definition at line 4897 of file fileio.c.

{
        int             ret;

        COB_CHK_PARMS (C$MAKEDIR, 1);

        ret = CBL_CREATE_DIR (dir);
        if (ret < 0) {
                ret = 128;
        }
        return ret;
}

Here is the call graph for this function:

void cob_close ( cob_file f,
const int  opt,
cob_field fnstatus 
)

Definition at line 3987 of file fileio.c.

{
        int     ret;

        f->flag_read_done = 0;

        if (f->special) {
                f->open_mode = COB_OPEN_CLOSED;
                RETURN_STATUS (COB_STATUS_00_SUCCESS);
        }
        if (f->open_mode == COB_OPEN_CLOSED) {
                RETURN_STATUS (COB_STATUS_42_NOT_OPEN);
        }

        if (f->flag_nonexistent) {
                ret = COB_STATUS_00_SUCCESS;
        } else {
#ifdef  WITH_SEQRA_EXTFH
                if (f->organization != COB_ORG_INDEXED) {
                        ret = extfh_cob_file_close (f, opt);
                } else {
#endif
                        ret = fileio_funcs[(int)f->organization]->close (f, opt);
#ifdef  WITH_SEQRA_EXTFH
                }
#endif
        }

        if (ret == COB_STATUS_00_SUCCESS) {
                switch (opt) {
                case COB_CLOSE_LOCK:
                        f->open_mode = COB_OPEN_LOCKED;
                        break;
                default:
                        f->open_mode = COB_OPEN_CLOSED;
                        break;
                }
        }

        RETURN_STATUS (ret);
}

Here is the caller graph for this function:

void cob_commit ( void  )

Definition at line 4273 of file fileio.c.

{
        struct file_list        *l;

        for (l = file_cache; l; l = l->next) {
                cob_file_unlock (l->file);
        }
}
void cob_default_error_handle ( void  )

Definition at line 4293 of file fileio.c.

{
        const char      *msg;
        unsigned char   *file_status;
        char            *filename;
        int             status;

        file_status = cob_error_file->file_status;
        status = cob_d2i(file_status[0]) * 10 + cob_d2i(file_status[1]);
        switch (status) {
        case COB_STATUS_10_END_OF_FILE:
                msg = "End of file";
                break;
        case COB_STATUS_14_OUT_OF_KEY_RANGE:
                msg = "Key out of range";
                break;
        case COB_STATUS_21_KEY_INVALID:
                msg = "Key order not ascending";
                break;
        case COB_STATUS_22_KEY_EXISTS:
                msg = "Record key already exists";
                break;
        case COB_STATUS_23_KEY_NOT_EXISTS:
                msg = "Record key does not exist";
                break;
        case COB_STATUS_30_PERMANENT_ERROR:
                msg = "Permanent file error";
                break;
        case COB_STATUS_35_NOT_EXISTS:
                msg = "File does not exist";
                break;
        case COB_STATUS_37_PERMISSION_DENIED:
                msg = "Permission denied";
                break;
        case COB_STATUS_41_ALREADY_OPEN:
                msg = "File already open";
                break;
        case COB_STATUS_42_NOT_OPEN:
                msg = "File not open";
                break;
        case COB_STATUS_43_READ_NOT_DONE:
                msg = "READ must be executed first";
                break;
        case COB_STATUS_44_RECORD_OVERFLOW:
                msg = "Record overflow";
                break;
        case COB_STATUS_46_READ_ERROR:
                msg = "Failed to read";
                break;
        case COB_STATUS_47_INPUT_DENIED:
                msg = "READ/START not allowed";
                break;
        case COB_STATUS_48_OUTPUT_DENIED:
                msg = "WRITE not allowed";
                break;
        case COB_STATUS_49_I_O_DENIED:
                msg = "DELETE/REWRITE not allowed";
                break;
        case COB_STATUS_51_RECORD_LOCKED:
                msg = "Record locked by another file connector";
                break;
        case COB_STATUS_52_EOP:
                msg = "A page overflow condition occurred";
                break;
        case COB_STATUS_57_I_O_LINAGE:
                msg = "LINAGE values invalid";
                break;
        case COB_STATUS_61_FILE_SHARING:
                msg = "File sharing conflict";
                break;
        case COB_STATUS_91_NOT_AVAILABLE:
                msg = "Runtime library is not configured for this operation";
                break;
        default:
                msg = "Unknown file error";
                break;
        }

        filename = cob_malloc (COB_MEDIUM_BUFF);
        cob_field_to_string (cob_error_file->assign, filename);
        cob_runtime_error ("%s (STATUS = %02d) File : '%s'", msg,
                                status, filename);
        free (filename);
}

Here is the call graph for this function:

void cob_delete ( cob_file f,
cob_field fnstatus 
)

Definition at line 4247 of file fileio.c.

{
        int     ret;
        int     read_done = f->flag_read_done;

        f->flag_read_done = 0;

        if (unlikely(f->open_mode == COB_OPEN_CLOSED ||
            f->open_mode != COB_OPEN_I_O)) {
                RETURN_STATUS (COB_STATUS_49_I_O_DENIED);
        }

        if (f->access_mode == COB_ACCESS_SEQUENTIAL && !read_done) {
                RETURN_STATUS (COB_STATUS_43_READ_NOT_DONE);
        }

        ret = fileio_funcs[(int)f->organization]->fdelete (f);

        if (unlikely(cob_do_sync && ret == 0)) {
                cob_sync (f, cob_do_sync);
        }

        RETURN_STATUS (ret);
}
void cob_exit_fileio ( void  )

Definition at line 4426 of file fileio.c.

{
        struct file_list        *l;

        for (l = file_cache; l; l = l->next) {
                if (l->file->open_mode != COB_OPEN_CLOSED &&
                     l->file->open_mode != COB_OPEN_LOCKED) {
                        cob_field_to_string (l->file->assign, runtime_buffer);
                        cob_close (l->file, 0, NULL);
                        fprintf (stderr, "WARNING - Implicit CLOSE of %s (\"%s\")\n",
                                l->file->select_name, runtime_buffer);
                        fflush (stderr);
                }
        }
#ifdef  USE_DB41
        free (record_lock_object);
        if (bdb_env) {
                bdb_env->lock_id_free (bdb_env, bdb_lock_id);
                bdb_env->close (bdb_env, 0);
        }
#endif
#if     defined(WITH_INDEX_EXTFH) || defined(WITH_SEQRA_EXTFH)
        extfh_cob_exit_fileio ();
#endif
}

Here is the call graph for this function:

void cob_file_release ( cob_file f)

Definition at line 5654 of file fileio.c.

{
        struct cobsort  *hp;
        cob_field       *fnstatus = NULL;
        int             ret;

        hp = f->file;
        if (likely(hp)) {
                fnstatus = hp->fnstatus;
        }
        ret = cob_file_sort_submit (f, f->record->data);
        switch (ret) {
        case 0:
                RETURN_STATUS (COB_STATUS_00_SUCCESS);
                break;
        default:
                if (likely(hp)) {
                        *(int *)(hp->sort_return) = 16;
                }
                RETURN_STATUS (COB_STATUS_30_PERMANENT_ERROR);
                break;
        }
}
void cob_file_return ( cob_file f)

Definition at line 5679 of file fileio.c.

{
        struct cobsort  *hp;
        cob_field       *fnstatus = NULL;
        int             ret;

        hp = f->file;
        if (likely(hp)) {
                fnstatus = hp->fnstatus;
        }
        ret = cob_file_sort_retrieve (f, f->record->data);
        switch (ret) {
        case 0:
                RETURN_STATUS (COB_STATUS_00_SUCCESS);
                break;
        case COBSORTEND:
                RETURN_STATUS (COB_STATUS_10_END_OF_FILE);
                break;
        default:
                if (likely(hp)) {
                        *(int *)(hp->sort_return) = 16;
                }
                RETURN_STATUS (COB_STATUS_30_PERMANENT_ERROR);
                break;
        }
}
void cob_file_sort_close ( cob_file f)

Definition at line 5631 of file fileio.c.

{
        struct cobsort  *hp;
        cob_field       *fnstatus = NULL;
        size_t          i;

        hp = f->file;
        if (likely(hp)) {
                fnstatus = hp->fnstatus;
                cob_free_list (hp->empty);
                for (i = 0; i < 4; i++) {
                        cob_free_list (hp->queue[i].first);
                        if (hp->file[i].fp != NULL) {
                                fclose (hp->file[i].fp);
                        }
                }
                free (hp);
        }
        f->file = NULL;
        RETURN_STATUS (COB_STATUS_00_SUCCESS);
}
void cob_file_sort_giving ( cob_file sort_file,
const size_t  varcnt,
  ... 
)

Definition at line 5544 of file fileio.c.

{
        cob_file        **fbase;
        struct cobsort  *hp;
        size_t          i;
        int             ret;
        int             opt;
        va_list         args;

        fbase = cob_malloc (varcnt * sizeof(cob_file *));
        va_start (args, varcnt);
        for (i = 0; i < varcnt; i++) {
                fbase[i] = va_arg (args, cob_file *);
        }
        va_end (args);
        for (i = 0; i < varcnt; i++) {
                cob_open (fbase[i], COB_OPEN_OUTPUT, 0, NULL);
        }
        while (1) {
                ret = cob_file_sort_retrieve (sort_file, sort_file->record->data);
                if (ret) {
                        if (ret == COBSORTEND) {
                                sort_file->file_status[0] = '1';
                                sort_file->file_status[1] = '0';
                        } else {
                                hp = sort_file->file;
                                *(int *)(hp->sort_return) = 16;
                                sort_file->file_status[0] = '3';
                                sort_file->file_status[1] = '0';
                        }
                        break;
                }
                for (i = 0; i < varcnt; i++) {
                        if (fbase[i]->special ||
                            fbase[i]->organization == COB_ORG_LINE_SEQUENTIAL) {
                                opt = COB_WRITE_BEFORE | COB_WRITE_LINES | 1;
                        } else {
                                opt = 0;
                        }
                        cob_copy_check (fbase[i], sort_file);
                        cob_write (fbase[i], fbase[i]->record, opt, NULL);
                }
        }
        for (i = 0; i < varcnt; i++) {
                cob_close (fbase[i], COB_CLOSE_NORMAL, NULL);
        }
        free (fbase);
}

Here is the call graph for this function:

void cob_file_sort_init ( cob_file f,
const int  nkeys,
const unsigned char *  collating_sequence,
void *  sort_return,
cob_field fnstatus 
)

Definition at line 5594 of file fileio.c.

{
        struct cobsort  *p;

        p = cob_malloc (sizeof (struct cobsort));
        p->fnstatus = fnstatus;
        p->size = f->record_max;
        p->r_size = f->record_max + sizeof(size_t);
        p->w_size = f->record_max + sizeof(size_t) + 1;
        p->pointer = f;
        p->sort_return = sort_return;
        *(int *)sort_return = 0;
        p->memory = (size_t)cob_sort_memory / (p->size + sizeof(struct cobitem));
        f->file = p;
        f->keys = cob_malloc (sizeof (struct cob_file_key) * nkeys);
        f->nkeys = 0;
        if (collating_sequence) {
                f->sort_collating = collating_sequence;
        } else {
                f->sort_collating = cob_current_module->collating_sequence;
        }
        RETURN_STATUS (COB_STATUS_00_SUCCESS);
}

Here is the call graph for this function:

void cob_file_sort_init_key ( cob_file f,
const int  flag,
cob_field field,
size_t  offset 
)

Definition at line 5621 of file fileio.c.

{
        f->keys[f->nkeys].flag = flag;
        f->keys[f->nkeys].field = field;
        f->keys[f->nkeys].offset = offset;
        f->nkeys++;
}
void cob_file_sort_using ( cob_file sort_file,
cob_file data_file 
)

Definition at line 5524 of file fileio.c.

{
        int             ret;

        cob_open (data_file, COB_OPEN_INPUT, 0, NULL);
        while (1) {
                cob_read (data_file, NULL, NULL, COB_READ_NEXT);
                if (data_file->file_status[0] != '0') {
                        break;
                }
                cob_copy_check (sort_file, data_file);
                ret = cob_file_sort_submit (sort_file, sort_file->record->data);
                if (ret) {
                        break;
                }
        }
        cob_close (data_file, COB_CLOSE_NORMAL, NULL);
}

Here is the call graph for this function:

void cob_init_fileio ( void  )

Definition at line 4379 of file fileio.c.

{
        char    *s;
        int     n;

        if ((s = getenv ("COB_SYNC")) != NULL) {
                if (*s == 'Y' || *s == 'y') {
                        cob_do_sync = 1;
                }
                if (*s == 'P' || *s == 'p') {
                        cob_do_sync = 2;
                }
        }
        if ((s = getenv ("COB_SORT_MEMORY")) != NULL) {
                n = atoi (s);
                if (n >= 1024*1024) {
                        cob_sort_memory = n;
                }
        }
        cob_file_path = getenv ("COB_FILE_PATH");
        if (cob_file_path) {
                if (!*cob_file_path || *cob_file_path == ' ') {
                        cob_file_path = NULL;
                }
        }
        cob_ls_nulls = getenv ("COB_LS_NULLS");
        cob_ls_fixed = getenv ("COB_LS_FIXED");

        file_open_env = cob_malloc (COB_SMALL_BUFF);
        file_open_name = cob_malloc (COB_SMALL_BUFF);
        file_open_buff = cob_malloc (COB_SMALL_BUFF);

#ifdef  USE_DB41
        bdb_home = getenv ("DB_HOME");
        join_environment ();
        record_lock_object = cob_malloc (1024);
        bdb_buff = cob_malloc (COB_SMALL_BUFF);
        rlo_size = 1024;
#endif

#if     defined(WITH_INDEX_EXTFH) || defined(WITH_SEQRA_EXTFH)
        extfh_cob_init_fileio (&sequential_funcs, &lineseq_funcs, &relative_funcs, &cob_file_write_opt);
#endif

}

Here is the call graph for this function:

void cob_open ( cob_file f,
const int  mode,
const int  sharing,
cob_field fnstatus 
)

Definition at line 3734 of file fileio.c.

{
        char            *p;
        char            *src;
        char            *dst;
        size_t          i;
        size_t          simple;
        int             was_not_exist = 0;
        struct stat     st;

        f->flag_read_done = 0;

        /* file was previously closed with lock */
        if (f->open_mode == COB_OPEN_LOCKED) {
                RETURN_STATUS (COB_STATUS_38_CLOSED_WITH_LOCK);
        }

        /* file is already open */
        if (f->open_mode != COB_OPEN_CLOSED) {
                RETURN_STATUS (COB_STATUS_41_ALREADY_OPEN);
        }

        f->last_open_mode = mode;
        f->flag_nonexistent = 0;
        f->flag_end_of_file = 0;
        f->flag_begin_of_file = 0;
        f->flag_first_read = 2;

        if (f->special) {
                if (f->special == 1) {
                        if (mode != COB_OPEN_INPUT) {
                                RETURN_STATUS (COB_STATUS_30_PERMANENT_ERROR);
                        }
                        f->file = stdin;
                        f->open_mode = mode;
                        RETURN_STATUS (COB_STATUS_00_SUCCESS);
                } else {
                        if (mode != COB_OPEN_OUTPUT) {
                                RETURN_STATUS (COB_STATUS_30_PERMANENT_ERROR);
                        }
                        f->file = stdout;
                        f->open_mode = mode;
                        RETURN_STATUS (COB_STATUS_00_SUCCESS);
                }
        }

        /* obtain the file name */
        cob_field_to_string (f->assign, file_open_name);

#ifdef  WITH_INDEX_EXTFH
        if (f->organization == COB_ORG_INDEXED) {
                int     ret;

                ret = extfh_indexed_locate (f, file_open_name);
                switch (ret) {
                case COB_NOT_CONFIGURED:
                        /* EXTFH requires OC to process the filename */
                        break;
                case COB_STATUS_00_SUCCESS:
                        /* EXTFH recognized the file */
                        goto file_available;
                default:
                        /* EXTFH detected an error */
                        RETURN_STATUS (ret);
                }
        }
#endif  /* WITH_INDEX_EXTFH */

#ifdef  WITH_SEQRA_EXTFH
        if (f->organization != COB_ORG_INDEXED) {
                int     ret;

                ret = extfh_seqra_locate (f, file_open_name);
                switch (ret) {
                case COB_NOT_CONFIGURED:
                        /* EXTFH requires OC to process the filename */
                        break;
                case COB_STATUS_00_SUCCESS:
                        /* EXTFH recognized the file */
                        goto file_available;
                default:
                        /* EXTFH detected an error */
                        RETURN_STATUS (ret);
                }
        }
#endif  /* WITH_SEQRA_EXTFH */

        if (cob_current_module->flag_filename_mapping) {
                src = file_open_name;
                dst = file_open_buff;
                simple = 1;
                /* expand envoronment variables */
                /* ex. "$TMPDIR/foo" -> "/tmp/foo" */
                while (*src) {
                        if (!isalnum (*src) && *src != '_' && *src != '-') {
                                simple = 0;
                        }
                        if (*src == '$') {
                                for (i = 1; ; i++) {
                                        if (!isalnum (src[i]) && src[i] != '_' && *src != '-') {
                                                break;
                                        }
                                }
                                memcpy (file_open_env, src + 1, i - 1);
                                file_open_env[i - 1] = 0;
                                if ((p = getenv (file_open_env)) != NULL) {
                                        strcpy (dst, p);
                                        dst += strlen (p);
                                }
                                src += i;
                        } else {
                                *dst++ = *src++;
                        }
                }
                *dst = 0;
                strncpy (file_open_name, file_open_buff, COB_SMALL_MAX);

                /* resolve by environment variables */
                /* ex. "TMPFILE" -> DD_TMPFILE, dd_TMPFILE, or TMPFILE */
                if (simple) {
                        for (i = 0; i < NUM_PREFIX; i++) {
                                snprintf (file_open_buff, COB_SMALL_MAX, "%s%s",
                                          prefix[i], file_open_name);
                                if ((p = getenv (file_open_buff)) != NULL) {
                                        strncpy (file_open_name, p, COB_SMALL_MAX);
                                        break;
                                }
                        }
                        if (i == NUM_PREFIX && cob_file_path) {
                                snprintf (file_open_buff, COB_SMALL_MAX, "%s/%s",
                                          cob_file_path, file_open_name);
                                strncpy (file_open_name, file_open_buff,
                                         COB_SMALL_MAX);
                        }
                }
        }
        /* check if the file exists */
#ifdef  USE_DB41
        if (f->organization == COB_ORG_INDEXED) {
                if ((bdb_env && bdb_nofile (file_open_name)) ||
                     (!bdb_env && stat (file_open_name, &st) == -1 && errno == ENOENT)) {
                        was_not_exist = 1;
                        if (mode != COB_OPEN_OUTPUT && f->flag_optional == 0) {
                                RETURN_STATUS (COB_STATUS_35_NOT_EXISTS);
                        }
                }
        } else if (stat (file_open_name, &st) == -1 && errno == ENOENT) {
#else   /* USE_DB41 */

#if     defined(WITH_CISAM) || defined(WITH_DISAM) || defined(WITH_VBISAM)
        if (f->organization == COB_ORG_INDEXED) {
                strncpy (file_open_buff, file_open_name, COB_SMALL_MAX);
                strcat (file_open_buff, ".idx");
                if (stat (file_open_buff, &st) == -1 && errno == ENOENT) {
                        was_not_exist = 1;
                        if (mode != COB_OPEN_OUTPUT && f->flag_optional == 0) {
                                RETURN_STATUS (COB_STATUS_35_NOT_EXISTS);
                        }
                }
                strncpy (file_open_buff, file_open_name, COB_SMALL_MAX);
                strcat (file_open_buff, ".dat");
                if (stat (file_open_buff, &st) == -1 && errno == ENOENT) {
                        was_not_exist = 1;
                        if (mode != COB_OPEN_OUTPUT && f->flag_optional == 0) {
                                RETURN_STATUS (COB_STATUS_35_NOT_EXISTS);
                        }
                }
        } else if (stat (file_open_name, &st) == -1 && errno == ENOENT) {
#else   /* WITH_CISAM || WITH_DISAM || WITH_VBISAM */
        if (stat (file_open_name, &st) == -1 && errno == ENOENT) {
#endif  /* WITH_CISAM || WITH_DISAM || WITH_VBISAM */

#endif  /* USE_DB41 */

                was_not_exist = 1;
                if (mode != COB_OPEN_OUTPUT && f->flag_optional == 0) {
                        RETURN_STATUS (COB_STATUS_35_NOT_EXISTS);
                }
        }

#if     defined(WITH_INDEX_EXTFH) || defined(WITH_SEQRA_EXTFH)
file_available:
#endif  /* WITH_INDEX_EXTFH || WITH_SEQRA_EXTFH */

        cob_cache_file (f);

        /* open the file */
#ifdef  WITH_SEQRA_EXTFH
        if (f->organization != COB_ORG_INDEXED) {
                int     ret;

                ret = extfh_cob_file_open (f, file_open_name, mode, sharing);
                switch (ret) {
                case COB_STATUS_00_SUCCESS:
                        f->open_mode = mode;
                        break;
                case COB_STATUS_35_NOT_EXISTS:
                        if (f->flag_optional) {
                                f->open_mode = mode;
                                f->flag_nonexistent = 1;
                                f->flag_end_of_file = 1;
                                f->flag_begin_of_file = 1;
                                RETURN_STATUS (COB_STATUS_05_SUCCESS_OPTIONAL);
                        }
                        break;
                }
                RETURN_STATUS (ret);
        }
#endif
#if     defined(WITH_CISAM) || defined(WITH_DISAM) || defined(WITH_VBISAM)
        if (f->organization == COB_ORG_INDEXED) {
                /* Do this here to avoid mangling of the status in the 'switch' below */
                RETURN_STATUS (fileio_funcs[(int)f->organization]->open (f, file_open_name, mode, sharing));
        }
#endif
        switch (fileio_funcs[(int)f->organization]->open (f, file_open_name, mode, sharing)) {
        case 0:
                f->open_mode = mode;
                if (f->flag_optional && was_not_exist) {
                        RETURN_STATUS (COB_STATUS_05_SUCCESS_OPTIONAL);
                } else {
                        RETURN_STATUS (COB_STATUS_00_SUCCESS);
                }
        case ENOENT:
                if (mode == COB_OPEN_EXTEND || mode == COB_OPEN_OUTPUT) {
                        RETURN_STATUS (COB_STATUS_30_PERMANENT_ERROR);
                }
                if (f->flag_optional) {
                        f->open_mode = mode;
                        f->flag_nonexistent = 1;
                        f->flag_end_of_file = 1;
                        f->flag_begin_of_file = 1;
                        RETURN_STATUS (COB_STATUS_05_SUCCESS_OPTIONAL);
                } else {
                        RETURN_STATUS (COB_STATUS_35_NOT_EXISTS);
                }
        case EACCES:
        case EISDIR:
        case EROFS:
                RETURN_STATUS (COB_STATUS_37_PERMISSION_DENIED);
        case EAGAIN:
        case COB_STATUS_61_FILE_SHARING:
                RETURN_STATUS (COB_STATUS_61_FILE_SHARING);
        case COB_STATUS_91_NOT_AVAILABLE:
                RETURN_STATUS (COB_STATUS_91_NOT_AVAILABLE);
        case COB_LINAGE_INVALID:
                RETURN_STATUS (COB_STATUS_57_I_O_LINAGE);
        default:
                RETURN_STATUS (COB_STATUS_30_PERMANENT_ERROR);
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cob_read ( cob_file f,
cob_field key,
cob_field fnstatus,
int  read_opts 
)

Definition at line 4081 of file fileio.c.

{
        int     ret;

        f->flag_read_done = 0;

        if (unlikely(f->flag_nonexistent)) {
                if (f->flag_first_read == 0) {
                        RETURN_STATUS (COB_STATUS_23_KEY_NOT_EXISTS);
                }
                f->flag_first_read = 0;
                RETURN_STATUS (COB_STATUS_10_END_OF_FILE);
        }

        /* sequential read at the end of file is an error */
        if (key == NULL) {
                if (f->flag_end_of_file && !(read_opts & COB_READ_PREVIOUS)) {
                        RETURN_STATUS (COB_STATUS_46_READ_ERROR);
                }
                if (f->flag_begin_of_file && (read_opts & COB_READ_PREVIOUS)) {
                        RETURN_STATUS (COB_STATUS_46_READ_ERROR);
                }
        }

        if (unlikely(f->open_mode == COB_OPEN_CLOSED
            || f->open_mode == COB_OPEN_OUTPUT
            || f->open_mode == COB_OPEN_EXTEND)) {
                RETURN_STATUS (COB_STATUS_47_INPUT_DENIED);
        }

#ifdef  USE_DB41
        if (f->organization == COB_ORG_INDEXED && bdb_env != NULL) {
                if (f->open_mode != COB_OPEN_I_O  ||
                    (f->lock_mode & COB_LOCK_EXCLUSIVE)) {
                        read_opts &= ~COB_READ_LOCK;
                } else if ((f->lock_mode & COB_LOCK_AUTOMATIC) &&
                   !(read_opts & COB_READ_NO_LOCK)) {
                        read_opts |= COB_READ_LOCK; 
                }
        } else {
                read_opts &= ~COB_READ_LOCK;
        }
#endif
        if (key) {
                ret = fileio_funcs[(int)f->organization]->read (f, key, read_opts);
        } else {
                ret = fileio_funcs[(int)f->organization]->read_next (f, read_opts);
        }

        switch (ret) {
        case COB_STATUS_00_SUCCESS:
                f->flag_first_read = 0;
                f->flag_read_done = 1;
                f->flag_end_of_file = 0;
                f->flag_begin_of_file = 0;
                if (f->record_size && f->organization != COB_ORG_LINE_SEQUENTIAL) {
                        cob_set_int (f->record_size, (int) f->record->size);
                }
                break;
        case COB_STATUS_10_END_OF_FILE:
                if (read_opts & COB_READ_PREVIOUS) {
                        f->flag_begin_of_file = 1;
                } else {
                        f->flag_end_of_file = 1;
                }
                break;
        }

        RETURN_STATUS (ret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cob_rewrite ( cob_file f,
cob_field rec,
const int  opt,
cob_field fnstatus 
)

Definition at line 4201 of file fileio.c.

{
        int     ret;
        int     read_done = f->flag_read_done;

        f->flag_read_done = 0;

        if (unlikely(f->open_mode == COB_OPEN_CLOSED ||
            f->open_mode != COB_OPEN_I_O)) {
                RETURN_STATUS (COB_STATUS_49_I_O_DENIED);
        }

        if (f->access_mode == COB_ACCESS_SEQUENTIAL && !read_done) {
                RETURN_STATUS (COB_STATUS_43_READ_NOT_DONE);
        }

        if (f->organization == COB_ORG_SEQUENTIAL) {
                if (f->record->size != rec->size) {
                        RETURN_STATUS (COB_STATUS_44_RECORD_OVERFLOW);
                }

                if (f->record_size) {
                        if (f->record->size != (size_t)cob_get_int (f->record_size)) {
                                RETURN_STATUS (COB_STATUS_44_RECORD_OVERFLOW);
                        }
                }
        }

/* RXW
#ifdef  USE_DB41
        if (f->organization != COB_ORG_INDEXED || bdb_env == NULL) {
                opt &= ~COB_WRITE_LOCK;
        }
#endif
*/

        ret = fileio_funcs[(int)f->organization]->rewrite (f, opt);

        if (unlikely(cob_do_sync && ret == 0)) {
                cob_sync (f, cob_do_sync);
        }

        RETURN_STATUS (ret);
}

Here is the call graph for this function:

void cob_rollback ( void  )

Definition at line 4283 of file fileio.c.

{
        struct file_list        *l;

        for (l = file_cache; l; l = l->next) {
                cob_file_unlock (l->file);
        }
}
void cob_start ( cob_file f,
const int  cond,
cob_field key,
cob_field fnstatus 
)

Definition at line 4052 of file fileio.c.

void cob_unlock_file ( cob_file f,
cob_field fnstatus 
)

Definition at line 3727 of file fileio.c.

{
        cob_file_unlock (f);
        RETURN_STATUS (COB_STATUS_00_SUCCESS);
}
void cob_write ( cob_file f,
cob_field rec,
const int  opt,
cob_field fnstatus 
)

Definition at line 4153 of file fileio.c.

{
        int     ret;

        f->flag_read_done = 0;

        if (f->access_mode == COB_ACCESS_SEQUENTIAL) {
                if (f->open_mode == COB_OPEN_CLOSED
                    || f->open_mode == COB_OPEN_INPUT
                    || f->open_mode == COB_OPEN_I_O) {
                        RETURN_STATUS (COB_STATUS_48_OUTPUT_DENIED);
                }
        } else {
                if (f->open_mode == COB_OPEN_CLOSED
                    || f->open_mode == COB_OPEN_INPUT
                    || f->open_mode == COB_OPEN_EXTEND) {
                        RETURN_STATUS (COB_STATUS_48_OUTPUT_DENIED);
                }
        }

        if (f->record_size) {
                f->record->size = cob_get_int (f->record_size);
        } else {
                f->record->size = rec->size;
        }

        if (f->record->size < f->record_min || f->record_max < f->record->size) {
                RETURN_STATUS (COB_STATUS_44_RECORD_OVERFLOW);
        }

/* RXW
#ifdef  USE_DB41
        if (f->organization != COB_ORG_INDEXED || bdb_env == NULL) {
                opt &= ~COB_WRITE_LOCK;
        }
#endif
*/

        ret = fileio_funcs[(int)f->organization]->write (f, opt);

        if (unlikely(cob_do_sync && ret == 0)) {
                cob_sync (f, cob_do_sync);
        }

        RETURN_STATUS (ret);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 197 of file fileio.c.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines