Ingres CL CP

From Ingres Community Wiki

Jump to: navigation, search

Ingres Compatability Library
Architecture - Overview - Suggestions - GL: BA - BT - ERGL - handy - HSH - LC - LL - MEGL - MM - MO - MU - PM - SP - TMGL - CL: CI - CK - CM - CP - CS - CSMT - CV - CX - DI - DL - DS - ER - ERold - EX - FP - GC - GV - handy - ID - JF - LG - LK - LO - ME - MH - NM - OL - PC - PE - QU - SA - SI - SR - ST - TC - TE - TH - TM - TR - UT

Contents

Compatibility Library Specification – CP

Abstract

This is the specification of the CP facility provided by the compatibility library used to provide special changed-priviledge access to files.

Revision: 1.1, 11-Nov-1997

Document History

  • Revision 1.1, last modified 11-Nov-1997.
    • Converted to HTML.
  • Revision 1.0, last modified 2-Jan-91.

Specification

Introduction

The CP routines are used to implement I/O in the protection domain of the logged in INGRES user. INGRES requires this functionality for its executables that run in ``privileged mode. On UNIX, there is an input and an output stream associated with a changed protection file operation. CPfile is a system dependent structure which manages these I/O streams.

Those INGRES processes which access database (ckp, jnl) files must run with the permissions of the ingres user. The CP abstraction is necessary because most UNIX implementations won't allow a process to assume the permissions of the real (login) user and then switch back to those of the effective (ingres) user. Therefore an INGRES process may not be able to read, write or remove a file though the real user may have such permission. This may necessitate the spawning of a process, which runs as the real user, to perform the desired CP function.

Many of these routines may be implemented as macros in the global header <cp.h>. These routines are system dependent.

Library

CL

Header File <cp.h>

The header file <cp.h> must be included before using any of the functions provided.

Executable Interface

The following functions are provided.

CPclose - close an open CP file

Close the I/O stream associated with CPfile.

Inputs:

CPfile pointer associated with I/O stream to be closed.

Outputs:

None

Returns:

OK if file closed correctly, otherwise system specific error status.

Definition:

STATUS
CPclose(CPfile)
CPFILE		*CPfile;

CPflush - flush output stream to CP file

Flush the output stream associated with CPfile.

Inputs:

CPfile pointer associated with stream to be flushed.

Outputs:

None

Returns:

OK if flush succeeded, otherwise system specific error status.

Definition:

STATUS
CPflush(CPfile)
CPFILE		*CPfile;

CPgetc - get character from input CP file

Return the next character from the input stream associated with CPfile. Returns EOF at end of file or upon read error.

Inputs:

CPfile pointer associated with stream character is to be read from.

Outputs:

None

Returns:

next character or EOF.

Definition:

i4
CPgetc(CPfile)
CPFILE		*CPfile;

CPopen - open a CP file

Open loc initializing the I/O streams associated with CPfile. The open will be successful if and only if the front-end process could open the file as requested. Allowed file_mode's are READ ("r), WRITE ("w) , and APPEND ("a). READ and WRITE open the file and position the stream pointer at the beginning of the file. APPEND opens the file for writing and positions the stream pointer at the end of the file. If file does not exist and the mode is "w or "a then CPopen() will create the file. If the file does not exist and the mode is "r then CPopen() will return error status. filetype is one of SI_BINARY (binary), SI_TEXT (text) or SI_VAR (variable length record). rec_length specifies the record length for SI_BINARY files. These constants are defined in <si.h>. filetype and rec_length may be ignored on some systems.

NOTE: Unlike FILE pointers, you must actually declare a CPFILE struct not a pointer to a CPFILE.

Inputs:

loc location containing file to be opened
file_mode mode to open file with, "r, "w, or "a.
file_type type of file, wither SI_TEXT, SI_VAR, or SI_BINARY.
rec_length record length for SI_BINARY files.

Outputs:

CPfile returned open file pointer

Returns:

OK if open succeeded, otherwise system specific error status.

Definition:

STATUS
CPopen(loc,file_mode,file_type,rec_length,CPfile)
LOCATION	  *loc;
char		  *file_mode;
i2		  file_type;
i4                rec_length;
CPFILE		  *CPfile;

CPread - read bytes from input CP file

Read up to "size bytes from the input stream associated with CPfile (already opened for reading) into space starting at *pointer. size is the maximum number of bytes to read. Return number of bytes read in count. A return of ENDFILE sets count to 0.

Inputs:

CPfile pointer associated with input stream
size maximum number of bytes to read

Outputs:

count number of bytes read.
pointer buffer filled in with data read from file.

Returns:

OK if read successful, ENDFILE on end of file, or system specific error status.

Definition:

STATUS
CPread(CPfile, size, count, pointer)
CPFILE    *CPfile;
i4        size;
i4        *count;
char      *pointer;

CPwrite - write bytes to CP file

Write an item of size size to output stream associated with CPfile (already opened for writing) starting from *pointer. Return number of bytes written in count. The setting of count is unsupported, but continues to exist for historical reasons. CPwrite will just return a failure status if all the bytes were not written.

Inputs:

size number of bytes to write
pointer bytes to write
CPfile pointer to stream opened for write

Outputs:

count returned byte count (UNSUPPORTED).

Returns:

OK if write successful, otherwise system specific error status.

Definition:

STATUS
CPwrite(size, pointer, count, CPfile)
i4      size;
char    *pointer;
i4      *count;
CPFILE  *CPfile; 


Ingres Compatability Library
Architecture - Overview - Suggestions - GL: BA - BT - ERGL - handy - HSH - LC - LL - MEGL - MM - MO - MU - PM - SP - TMGL - CL: CI - CK - CM - CP - CS - CSMT - CV - CX - DI - DL - DS - ER - ERold - EX - FP - GC - GV - handy - ID - JF - LG - LK - LO - ME - MH - NM - OL - PC - PE - QU - SA - SI - SR - ST - TC - TE - TH - TM - TR - UT

Personal tools
Developing With