home *** CD-ROM | disk | FTP | other *** search
- /* ==( io/src/icisam.c )== */
-
- /* ----------------------------------------------- */
- /* Pro-C Copyright (C) 1988 - 1990 Vestronix Inc. */
- /* Modification to this source is not supported */
- /* by Vestronix Inc. */
- /* All Rights Reserved */
- /* ----------------------------------------------- */
- /* Written NA 24-Feb-88 */
- /* Modified VvA 28-Mar-90 See comments below */
- /* ----------------------------------------------- */
- /* %W% (%H% %T%) */
-
- /*
- * Modifications
- *
- * 28-Mar-90 VvA - adjustments for locking modes, transactions
- * 01-Feb-90 VvA - openmode enabled, some bug fixes
- * 14-Dec-89 VvA - V.2 modifications
- * 01-Aug-89 VvA - Modified for generic I/O interface
- * 01-Sep-88 VvA - Numerical & segmented keys added
- */
-
- /* C-ISAM specific I/O calls via general IOGEN.C interface */
-
-
- # include <stdio.h>
- # include <isam.h>
- # include <iodef.h>
- # include <iomsg.h>
- # include <proc.io>
- # include <bench.h>
- # include <iosup.h>
-
-
- #define ENOFILE 2 /* C-ISAM */
-
-
- /* C-ISAM prototypes */
- #ifdef ANSI
- int isstart(int, struct keydesc *, int, char *, int);
- int isbuild(char *, int, struct keydesc *, int);
- int iserase(char *);
- int isopen(char *, int);
- int isclose(int);
- int isread(int, char *, int);
- int iswrcurr(int, char *);
- int isrewcurr(int, char *);
- int isflush(int);
- int isaddindex(int, struct keydesc *);
- int isindexinfo(int, struct keydesc *, int);
- int isdelcurr(int);
- int isrelease(int);
- int isbegin(void);
- int isrollback(void);
- int iscommit(void);
- int islogopen(char *);
- int islogclose(void);
- int ldchar(char *, int, char *);
- int stchar(char *, char *, int);
- int stdbl(double, char *);
- int stfloat(float, char *);
- int stlong(long, char *);
- double lddbl(char *);
- double ldfloat(char *);
- long ldlong(char *);
- #else
- int isstart();
- int isbuild();
- int iserase();
- int isopen();
- int isclose();
- int isread();
- int iswrcurr();
- int isrewcurr();
- int isflush();
- int isaddindex();
- int isindexinfo();
- int isdelcurr();
- int isrelease();
- int isbegin();
- int isrollback();
- int iscommit();
- int islogopen();
- int islogclose();
- int ldchar();
- int stchar();
- int stdbl();
- int stfloat();
- int stlong();
- long ldlong();
- double lddbl();
- double ldfloat();
- #endif
-
-
- /* Function prototypes */
- # ifdef ANSI
- static int i_addrec(int, char *);
- static int i_close_file(int, char *);
- static int i_commit(int, char *);
- static int i_delrec(int, char *);
- static int i_filename(int, char *);
- static int i_findkey(int, char *);
- static int i_firstkey(int, char *);
- static int i_init_file(int, char *);
- static int i_lastkey(int, char *);
- static int i_lockrec(int, char *);
- static int i_login(int, char *);
- static int i_logoff(int, char *);
- static int i_nextrec(int, char *);
- static int i_open_file(int, char *);
- static int i_prevrec(int, char *);
- static int i_rereadrec(int, char *);
- static int i_rollback(int, char *);
- static int i_selectinx(int, char *);
- static int i_transact(int, char *);
- static int i_unlock_rec(int, char *);
- static int i_updrec(int, char *);
- static int create_file(int);
- static int load_keys(int);
- static int io_xlate(int, int, char *);
- static int start_translog(void);
- static void buf2isam(int, char *, char *);
- static void isam2buf(int, char *, char *);
- static void close_translog(void);
- # else
- static int i_addrec();
- static int i_close_file();
- static int i_commit();
- static int i_delrec();
- static int i_filename();
- static int i_findkey();
- static int i_firstkey();
- static int i_init_file();
- static int i_lastkey();
- static int i_lockrec();
- static int i_login();
- static int i_logoff();
- static int i_nextrec();
- static int i_open_file();
- static int i_prevrec();
- static int i_rereadrec();
- static int i_rollback();
- static int i_selectinx();
- static int i_transact();
- static int i_unlock_rec();
- static int i_updrec();
- static int create_file();
- static int load_keys();
- static int io_xlate();
- static int start_translog();
- static void buf2isam();
- static void isam2buf();
- static void close_translog();
- # endif
-
-
- static int IS_OPENMODE;
- static int IS_LOCKMODE;
- static int IS_TRANSACT = 0;
- static int logisopen = FALSE;
- static struct keydesc fkey[MAX_FILES][MAX_KEYS]; /* keydescs for each file */
- static char storbuff[MAX_RECLEN]; /* for C-ISAM copy of data record */
-
-
- /*
- *
- * Interface Functions
- *
- */
-
-
- /*
- * Sets up File Name extension.
- */
- static int i_filename(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- for ( ; (*buffer != '.') && (*buffer != NULL); buffer++)
- ;
- *buffer = NULL;
-
- return(IOGOOD);
- }
-
- /*
- * Initialize file
- */
- static int i_init_file(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- return(IOGOOD);
- }
-
-
- /*
- * File open function
- */
- static int i_open_file(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
- struct dictinfo ch;
- struct fd_def *fptr = &fd[fd_sys];
-
- if (fptr->openmode & OUTPUT_FLAG)
- iserase(fptr->filname); /* for OUTPUT, delete existing files */
-
- if (fptr->openmode & UPDATE_FLAG)
- IS_OPENMODE = ISINOUT;
- else if (fptr->openmode & INPUT_FLAG)
- IS_OPENMODE = ISINPUT;
- else
- IS_OPENMODE = ISOUTPUT; /* either OUTPUT or APPEND */
-
- if (fptr->openmode & P_TRANSACT)
- {
- IS_TRANSACT = ISTRANS;
- if (start_translog())
- return(IOERROR);
- }
-
- if ((stat = isopen(fptr->filname, ISMANULOCK+IS_OPENMODE+IS_TRANSACT)) < SUCCESS)
- { /* try to create the file */
- if (fptr->openmode & INPUT_FLAG)
- {
- stat = io_xlate(fd_sys, iserrno, "CISM OPEN1");
- close_translog();
- return(stat);
- }
-
- if ((stat = create_file(fd_sys)) <= IOERROR)
- {
- close_translog();
- return(IOERROR);
- }
- }
- else /* at this point, the file is successfully opened */
- {
- isindexinfo(stat, &ch, 0); /* stat contains file descriptor */
-
- if(ch.di_recsize != fptr->rec_len+1) /* not same reclen as expected */
- {
- errmsg(FileRecLenChg_s, fptr->filname);
- fptr->fd_num = stat; /* ensure closing the correct file */
- i_close_file(fd_sys, "");
- return(IOERROR);
- }
-
- load_keys(fd_sys);
- }
-
- fptr->fd_num = stat; /* retain the file descriptor */
- return(IOGOOD);
- }
-
-
- /*
- * Initialize and open C-ISAM transaction log file
- * - the file should be named <databasename>.log rather than "recovery"
- * when some form of overall database or project name is implemented
- */
- static int start_translog()
- {
- if (logisopen)
- return(TRUE);
-
- if (access("recovery.log", 00) < 0)
- {
- if (creat("recovery.log", S_IWRITE) == -1)
- {
- errmsg(FileTrnsLogCreate);
- return(IOERROR);
- }
- }
- if (islogopen("recovery.log") == -1)
- {
- errmsg(FileTrnsLogOpen);
- return(IOERROR);
- }
- logisopen = TRUE;
- return(IOGOOD);
- }
-
-
- /*
- * C-ISAM create file function
- * - file has to be created in exclusive mode to set up indexes; it is
- * then closed and reopened in shared mode; stat is file descriptor
- */
- static int create_file(fd_sys)
- int fd_sys;
- {
- int stat, j, nkeys;
- char fname[FILENAME_LEN];
- struct fd_def *fptr = &fd[fd_sys];
-
- strcpy(fname, fptr->filname);
- strcat(fname, ".dat");
- if (access(fname, 00) == 0) /* file already exists, do not clobber */
- { /* iserrno here will be from isopen() */
- errmsg("Data file %s already exists", fptr->filname);
- return(io_xlate(fd_sys, iserrno, "CISM OPEN2"));
- }
-
- nkeys = load_keys(fd_sys);
-
- if (isbuild(fptr->filname, fptr->rec_len+1, &fkey[fd_sys][0], ISINOUT+ISEXCLLOCK+IS_TRANSACT) < SUCCESS)
- return(io_xlate(fd_sys, iserrno, "CISM CRT1"));
-
- if ((stat = isopen(fptr->filname, ISINOUT+ISEXCLLOCK+IS_TRANSACT)) < SUCCESS)
- return(io_xlate(fd_sys, iserrno, "CISM CRT2"));
-
- for (j = 1; j < nkeys; j++) /* create remaining indexes */
- if (isaddindex(stat, &fkey[fd_sys][j]))
- return(io_xlate(fd_sys, iserrno, "CISM IXCRT"));
-
- if (isclose(fptr->fd_num))
- return(io_xlate(fd_sys, iserrno, "CISM CRT3"));
-
- if ((stat = isopen(fptr->filname, ISMANULOCK+IS_OPENMODE+IS_TRANSACT)) < SUCCESS)
- return(io_xlate(fd_sys, iserrno, "CISM CRT4"));
-
- return(stat);
- }
-
-
- /*
- * C-ISAM key load function
- * - loads into C-ISAM key descriptor structure
- */
- static int load_keys(fd_sys)
- int fd_sys;
- {
- int fx, m, n = 0;
- struct fd_def *fptr = &fd[fd_sys];
-
- while (fptr->keys[n].segcount != -1)
- {
- for (m = 0; m < fptr->keys[n].segcount; m++)
- {
- fkey[fd_sys][n].k_part[m].kp_start = fptr->keys[n].segstart[m];
- fkey[fd_sys][n].k_part[m].kp_leng = fptr->keys[n].seglen[m];
-
- fx = fptr->keys[n].fldindex[m];
- switch(fptr->flds[fx].fldtype) /* data type of key segment */
- {
- case CHRTYP :
- fkey[fd_sys][n].k_part[m].kp_type = CHARTYPE;
- break;
- case INTTYP :
- fkey[fd_sys][n].k_part[m].kp_leng = INTSIZE;
- fkey[fd_sys][n].k_part[m].kp_type = INTTYPE;
- break;
- case LNGTYP :
- fkey[fd_sys][n].k_part[m].kp_leng = LONGSIZE;
- fkey[fd_sys][n].k_part[m].kp_type = LONGTYPE;
- break;
- case FLTTYP :
- fkey[fd_sys][n].k_part[m].kp_type = FLOATTYPE;
- fkey[fd_sys][n].k_part[m].kp_leng = FLOATSIZE;
- break;
- case DBLTYP :
- fkey[fd_sys][n].k_part[m].kp_type = DOUBLETYPE;
- fkey[fd_sys][n].k_part[m].kp_leng = DOUBLESIZE;
- break;
- case DATTYP :
- if (fptr->keys[n].seglen[m] == 6)
- fkey[fd_sys][n].k_part[m].kp_type = CHARTYPE;
- else
- {
- fkey[fd_sys][n].k_part[m].kp_leng = LONGSIZE;
- fkey[fd_sys][n].k_part[m].kp_type = LONGTYPE;
- }
- break;
- }
- }
- fkey[fd_sys][n].k_nparts = m; /* segment count for this key */
-
- if (fptr->keys[n].keytype == KEY_DUPLICATE)
- fkey[fd_sys][n].k_flags = ISDUPS;
- else
- fkey[fd_sys][n].k_flags = ISNODUPS;
-
- n++; /* increment total key count */
- }
- return(n);
- }
-
-
- /*
- * File close function
- */
- static int i_close_file(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
- struct fd_def *fptr = &fd[fd_sys];
-
- if (stat = isclose(fptr->fd_num))
- return(io_xlate(fd_sys, iserrno, "CISM CLOSE"));
-
- fptr->active = NO;
- close_translog();
- return(IOGOOD);
- }
-
-
- /*
- * Close recovery.log file, if used
- */
- static void close_translog()
- {
- int n;
-
- if (logisopen)
- {
- for (n = 0; n < MAX_FILES; n++) /* all files closed yet? */
- if (fd[n].active)
- return;
-
- islogclose();
- logisopen = FALSE;
- }
- }
-
-
- /*
- * Select an index to perform processing on - already done in IOGEN.C
- * - also sets C-ISAM's own lock modes for subsequent read
- */
- static int i_selectinx(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- if (fd[fd_sys].lockmode == NOLOCK)
- IS_LOCKMODE = NOLOCK;
- else
- IS_LOCKMODE = ISLOCK; /* C-ISAM's own lock flag */
- return(IOGOOD);
- }
-
- /*
- * Find a record by key value
- */
- static int i_findkey(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat, ck, IS_MD;
- struct fd_def *fptr = &fd[fd_sys];
-
- buf2isam(fd_sys, buffer, storbuff);
- ck = fptr->cur_key;
- IS_MD = (fptr->exact ? ISEQUAL : ISGTEQ);
-
- if((stat = isstart(fptr->fd_num, &fkey[fd_sys][ck], 0, storbuff, IS_MD)) < SUCCESS)
- return(io_xlate(fd_sys, iserrno, "CISM FIND 1"));
-
- if((stat = isread(fptr->fd_num, storbuff, IS_MD + IS_LOCKMODE)) < SUCCESS)
- return(io_xlate(fd_sys, iserrno, "CISM FIND 2"));
-
- isam2buf(fd_sys, buffer, storbuff);
- return(IOGOOD);
- }
-
- /*
- * Find first record in the file
- */
- static int i_firstkey(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat, ck;
- struct fd_def *fptr = &fd[fd_sys];
-
- ck = fptr->cur_key;
-
- if((stat = isstart(fptr->fd_num, &fkey[fd_sys][ck], 0, storbuff, ISFIRST)) < SUCCESS)
- return(io_xlate(fd_sys, iserrno, "CISM FRST 1"));
-
- if ((stat = isread(fptr->fd_num, storbuff, ISNEXT + IS_LOCKMODE)) < SUCCESS)
- return(io_xlate(fd_sys, iserrno, "CISM FRST 2"));
-
- isam2buf(fd_sys, buffer, storbuff);
- return(IOGOOD);
- }
-
- /*
- * Find last physical record in the file
- */
- static int i_lastkey(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat, ck;
- struct fd_def *fptr = &fd[fd_sys];
-
- ck = fd[fd_sys].cur_key;
-
- if((stat = isstart(fptr->fd_num, &fkey[fd_sys][ck], 0, storbuff, ISLAST)) < SUCCESS)
- return((iserrno == EENDFILE) ? IOEOF : io_xlate(fd_sys, iserrno, "CISM LAST 1"));
-
- if((stat = isread(fptr->fd_num, storbuff, ISPREV + IS_LOCKMODE)) < SUCCESS)
- return((iserrno == EENDFILE) ? IOEOF : io_xlate(fd_sys, iserrno, "CISM LAST 2"));
-
- isam2buf(fd_sys, buffer, storbuff);
- return(IOGOOD);
- }
-
- /*
- * Find next record in the file
- */
- static int i_nextrec(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
- struct fd_def *fptr = &fd[fd_sys];
-
- buf2isam(fd_sys, buffer, storbuff);
-
- if ((stat = isread(fptr->fd_num, storbuff, ISNEXT + IS_LOCKMODE)) < SUCCESS)
- return((iserrno == EENDFILE) ? IOEOF : io_xlate(fd_sys, iserrno, "CISM NEXT"));
-
- isam2buf(fd_sys, buffer, storbuff);
- return(IOGOOD);
- }
-
- /*
- * Find previous record in the file
- */
- static int i_prevrec(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
- struct fd_def *fptr = &fd[fd_sys];
-
- buf2isam(fd_sys, buffer, storbuff);
-
- if ((stat = isread(fptr->fd_num, storbuff, ISPREV + IS_LOCKMODE)) < SUCCESS)
- return((iserrno == EENDFILE) ? IOTOF : io_xlate(fd_sys, iserrno, "CISM PREV"));
-
- isam2buf(fd_sys, buffer, storbuff);
- return(IOGOOD);
- }
-
- /*
- * Re-read/reposition record pointer function - if required
- */
- static int i_rereadrec(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- return(i_findkey(fd_sys, buffer));
- }
-
-
- /*
- * Add a new record.
- */
- static int i_addrec(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
- struct fd_def *fptr = &fd[fd_sys];
-
- buf2isam(fd_sys, buffer, storbuff); /* NEW */
-
- if ((stat = iswrcurr(fptr->fd_num, storbuff)) < SUCCESS)
- return(io_xlate(fd_sys, iserrno, "CISM ADD"));
-
- isflush(fptr->fd_num);
- return(IOGOOD);
- }
-
- /*
- * Update the current record.
- */
- static int i_updrec(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
- struct fd_def *fptr = &fd[fd_sys];
-
- buf2isam(fd_sys, buffer, storbuff);
-
- if ((stat = isrewcurr(fptr->fd_num, storbuff)) < SUCCESS)
- return(io_xlate(fd_sys, iserrno, "CISM UPD"));
-
- isflush(fptr->fd_num);
- return(IOGOOD);
- }
-
- /*
- * Delete the current record.
- */
- static int i_delrec(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
-
- if (stat = isdelcurr(fd[fd_sys].fd_num))
- return io_xlate(fd_sys, iserrno, "CISM DEL");
-
- return(IOGOOD);
- }
-
- /*
- * Lock Record - rereads current record into storbuff to lock
- * - to preserve edits, storbuff is NOT converted to PRO-C buffer
- */
- static int i_lockrec(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
- struct fd_def *fptr = &fd[fd_sys];
-
- if ((stat = isread(fptr->fd_num, storbuff, ISCURR + IS_LOCKMODE)) < SUCCESS)
- {
- if (iserrno == EENDFILE) /* bypass retry count if EOF/TOF */
- return(IOGOOD);
- return(io_xlate(fd_sys, iserrno, "CISM LOCK"));
- }
-
- return(IOGOOD);
- }
-
- /*
- * Unlock Record
- */
- static int i_unlock_rec(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
-
- if (stat = isrelease(fd[fd_sys].fd_num))
- return(io_xlate(fd_sys, iserrno, "CISM ULCK"));
-
- return(IOGOOD);
- }
-
- /*
- * Login
- */
- static int i_login(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- return(IOGOOD);
- }
-
- /*
- * Logoff
- */
- static int i_logoff(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- return(IOGOOD);
- }
-
- /*
- * End (Commit) transaction - releases any outstanding locks
- */
- static int i_commit(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
-
- if (!IS_TRANSACT)
- return(IOGOOD);
-
- if (stat = iscommit())
- {
- errmsg(FileTrnsCommit);
- return(io_xlate(fd_sys, iserrno, "CISM ETRN"));
- }
- return(IOGOOD);
- }
-
- /*
- * Rollback transaction
- */
- static int i_rollback(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
-
- if (!IS_TRANSACT)
- return(IOGOOD);
-
- if (stat = isrollback())
- {
- errmsg(FileTrnsRlback);
- return(io_xlate(fd_sys, iserrno, "CISM ATRN"));
- }
- return(IOGOOD);
- }
-
- /*
- * Start transaction
- */
- static int i_transact(fd_sys, buffer)
- int fd_sys;
- char *buffer;
- {
- int stat;
-
- if (!IS_TRANSACT)
- return(IOGOOD);
-
- if (stat = isbegin())
- {
- errmsg(FileTrnsBegin);
- return(io_xlate(fd_sys, iserrno, "CISM BTRN"));
- }
- return(IOGOOD);
- }
-
-
- /*
- * Convert record to C-ISAM form from PRO-C buffer format before storing
- */
- static void buf2isam(fd_sys, P_buff, CI_buff)
- int fd_sys;
- char *P_buff, *CI_buff;
- {
- int itmp;
- long ltmp;
- float ftmp;
- double dtmp;
- int x = 0, foff, flen;
- struct fd_def *fptr = &fd[fd_sys];
-
- zerorec(CI_buff, fptr->rec_len+1);
-
- while (fptr->flds[x].fldname) /* NULL fieldname terminates list */
- {
- foff = fptr->flds[x].fldstart;
- flen = fptr->flds[x].fldlen;
- switch(fptr->flds[x].fldtype)
- {
- case DATTYP :
- if (flen == 6)
- stchar(&P_buff[foff], &CI_buff[foff], flen);
- else
- {
- bytecpy(<mp, &P_buff[foff], flen);
- stlong(ltmp, &CI_buff[foff]);
- }
- break;
- case LOGTYP :
- case MEMTYP :
- case CHRTYP :
- stchar(&P_buff[foff], &CI_buff[foff], flen);
- break;
- case INTTYP :
- bytecpy(&itmp, &P_buff[foff], flen);
- stint(itmp, &CI_buff[foff]);
- break;
- case LNGTYP :
- bytecpy(<mp, &P_buff[foff], flen);
- stlong(ltmp, &CI_buff[foff]);
- break;
- case FLTTYP :
- bytecpy(&ftmp, &P_buff[foff], flen);
- /* stfloat(ftmp, &CI_buff[foff]); (C-ISAM bug) */
- break;
- case DBLTYP :
- bytecpy(&dtmp, &P_buff[foff], flen);
- stdbl(dtmp, &CI_buff[foff]);
- break;
- }
- x++;
- }
- }
-
- /*
- * Convert record to PRO-C buffer format from C-ISAM form before returning
- */
- static void isam2buf(fd_sys, P_buff, CI_buff)
- int fd_sys;
- char *P_buff, *CI_buff;
- {
- int itmp;
- long ltmp;
- float ftmp;
- double dtmp;
- int x = 0, foff, flen;
- char tbuff[MAX_FLDLEN]; /* dummy buffer for char field extraction */
- struct fd_def *fptr = &fd[fd_sys];
-
- zerorec(P_buff, fptr->rec_len);
-
- while (fptr->flds[x].fldname) /* NULL fieldname terminates list */
- {
- foff = fptr->flds[x].fldstart;
- flen = fptr->flds[x].fldlen;
- switch(fptr->flds[x].fldtype)
- {
- case DATTYP :
- if (flen == 6)
- {
- ldchar(&CI_buff[foff], flen, tbuff);
- bytecpy(&P_buff[foff], tbuff, flen);
- }
- else
- {
- ltmp = ldlong(&CI_buff[foff]);
- bytecpy(&P_buff[foff], <mp, flen);
- }
- break;
- case LOGTYP :
- case MEMTYP :
- case CHRTYP :
- ldchar(&CI_buff[foff], flen, tbuff);
- bytecpy(&P_buff[foff], tbuff, flen);
- break;
- case INTTYP :
- itmp = ldint(&CI_buff[foff]);
- bytecpy(&P_buff[foff], &itmp, flen);
- break;
- case LNGTYP :
- ltmp = ldlong(&CI_buff[foff]);
- bytecpy(&P_buff[foff], <mp, flen);
- break;
- case FLTTYP :
- /* dtmp = ldfloat(&CI_buff[foff]); (C-ISAM bug!) */
- ftmp = 0; /* for now ... (float)dtmp; */
- bytecpy(&P_buff[foff], &ftmp, flen);
- break;
- case DBLTYP :
- dtmp = lddbl(&CI_buff[foff]);
- bytecpy(&P_buff[foff], &dtmp, flen);
- break;
- }
- x++;
- }
- }
-
-
- /*
- * This routine translates C-ISAM Error codes into PRO-C error codes.
- * If no PRO-C equivalent, displays the error number.
- */
- static int io_xlate(fd_sys, ernum, rtnname)
- int fd_sys;
- int ernum;
- char *rtnname;
- {
- switch(ernum)
- {
- case EDUPL :
- return(IODUP);
- case ENOTOPEN :
- return(IOBADOPEN);
- case ENOFILE :
- return(IONOFILE);
- case EENDFILE :
- case ENOREC :
- case ENOCURR :
- return(IONOKEY);
- case ELOCKED :
- case EFLOCKED :
- return(IOLOCKED);
- case ELOGWRIT :
- case ENOTRANS :
- case ENOBEGIN :
- return(IONOTRANS);
- }
-
- if (fd_sys >= 0)
- errmsg(FileDbgError_sdss, "C-ISAM", ernum, fd[fd_sys].filname, rtnname);
- else /* if routines called from generated apps without valid fd_sys */
- errmsg(FileDbgError_sds, "C-ISAM", ernum, rtnname);
- return(IOERROR);
- }
-
-
- /*
- * Assign section
- */
-
- void assign_IO_CI(dbnum)
- int dbnum;
- {
- Fntab[dbnum - 1][0] = (int(*)())0; /* Empty */
- Fntab[dbnum - 1][1] = i_init_file;
- Fntab[dbnum - 1][2] = i_open_file;
- Fntab[dbnum - 1][3] = i_close_file;
- Fntab[dbnum - 1][4] = i_addrec;
- Fntab[dbnum - 1][5] = i_delrec;
- Fntab[dbnum - 1][6] = i_findkey;
- Fntab[dbnum - 1][7] = i_firstkey;
- Fntab[dbnum - 1][8] = i_lastkey;
- Fntab[dbnum - 1][9] = i_lockrec;
- Fntab[dbnum - 1][10] = i_nextrec;
- Fntab[dbnum - 1][11] = i_prevrec;
- Fntab[dbnum - 1][12] = i_unlock_rec;
- Fntab[dbnum - 1][13] = i_updrec;
- Fntab[dbnum - 1][14] = i_commit;
- Fntab[dbnum - 1][15] = i_login;
- Fntab[dbnum - 1][16] = i_logoff;
- Fntab[dbnum - 1][17] = i_rollback;
- Fntab[dbnum - 1][18] = i_transact;
- Fntab[dbnum - 1][19] = i_selectinx;
- Fntab[dbnum - 1][20] = i_rereadrec;
- Fntab[dbnum - 1][21] = i_filename;
- }
-