📄 db.doc
字号:
options - Create options string
The option string contains a list of create options
seperated by commas. The following options are supported:
SEQ - Sequential file organization
RAN - Random file organization
IDX - Index file organization
VAR - Variable file organization
BLK = nnn - Size of block
REC = nnn - Size of record
BASE = nnn - Size of Random file base area
(Should be a prime number)
KEY = nnn - Size of the record key
ATR = nnn - Size of Attribute block
DUPS - Duplicate record keys allowed
NODUPS - Duplicate record keys NOT allowd
O P T I O N T A B L E
=========== =========
+===============================+
| -- File Organizations -- |
+===============+=======+=======+=======+=======+
| - Options - | SEQ | RAN | IDX | VAR |
+===============+=======+=======+=======+=======+
| SEQ | REQ | - | - + - |
+---------------+-------+-------+-------+-------+
| RAN | - | REQ | - + - |
+---------------+-------+-------+-------+-------+
| IDX | - | - | REQ + - |
+---------------+-------+-------+-------+-------+
| VAR | - | - | - + REQ |
+---------------+-------+-------+-------+-------+
| BLK | OPT | OPT | OPT + OPT |
+---------------+-------+-------+-------+-------+
| REC | REQ | REQ | REQ + REQ |
+---------------+-------+-------+-------+-------+
| BASE | - | REQ | - + - |
+---------------+-------+-------+-------+-------+
| KEY | - | REQ | REQ + - |
+---------------+-------+-------+-------+-------+
| ATR | OPT | OPT | OPT + OPT |
+---------------+-------+-------+-------+-------+
| DUPS | - | - | OPT + - |
+---------------+-------+-------+-------+-------+
| NODUPS | - | - | OPT + - |
+===============+=======+=======+=======+=======+
REQ = Required OPT = Optional - = Doesn't Apply
o Examples:
df = db_create("c:\\data", "test.dat", "SEQ, REC=32");
df = db_create("", "test.dat", "RAN,REC=32,KEY=2,BASE=29");
df = db_create("", "test.dat", "IDX, REC=50, KEY=5");
o Returns
This function returns a pointer to the data file descriptor
block for the newly created data file. This value should be
used for future references to the data file. The status of
the data file is open.
The return status is available in the global db_error. If
an error occurs the new data file is not created and a null
descriptor pointer is returned.
+-----------+ ------------------------------- +-----------+
| db_delete | - Delete the Current Record - | db_delete |
+-----------+ ------------------------------- +-----------+
o Summary
#include <db.h>
void db_delete(df)
DATA_FILE df;
o Description
This function is used to delete the Current Record from the
data file specified by df.
This function must be preceeded by some function that
establishes the Current Record for the data file.
o Returns
The completion status is returned in the global db_error.
A non-zero value indicates an error. The Current Record
for the data file is reset to NONE.
+---------+ ------------------------- +---------+
| db_dict | - Dictionary Routines - | db_dict |
+---------+ ------------------------- +---------+
o Description
The dictionary routines can be used to maintain a simple
object dictionary. Objects are of arbitrary size and are
referenced by name and type. A dictionary may be dumped
to or loaded from a VAR file. If the DB_DICT routines are
to be used, VAR file support must be included in the
library.
A dictionary is memory resident. It makes a good place
to store a non-homogenous collection of objects (records).
The following functions are supported:
db_dict_add - Dict Add Object
db_dict_close - Dict Close
db_dict_delete - Dict Object Delete
db_dict_delete_all - Dict Delete All
db_dict_dump - Dict Dump to a File
db_dict_find - Dict Find Object
db_dict_find_all - Dict Find All
db_dict_init - Dict Initialize
db_dict_load - Dict Load From File
+--------------+ --------------------- +--------------+
| db_dict_init | - Dict Initialize - | db_dict_init |
+--------------+ --------------------- +--------------+
o Summary
#include <db.h>
DICT db_dict_init()
o Description
This function is used to create a new dictionary. It must
be called before any other dictionary routines.
o Returns
A pointer to the new dictionary is returned. If an error
occurs a NULL pointer is returned and db_error contains
the error code.
+---------------+ ---------------- +---------------+
| db_dict_close | - Dict Close - | db_dict_close |
+---------------+ ---------------- +---------------+
o Summary
#include <db.h>
void db_dict_close(dict)
DICT dict;
o Description
This function is used to close up the dictionary dict.
All allocated storage will be freed. The dict variable
should be set to NULL after a close.
o Returns
The completion status is returned in the global db_error.
A non-zero value indicates an error.
+-------------+ --------------------- +-------------+
| db_dict_add | - Dict Add Object - | db_dict_add |
+-------------+ --------------------- +-------------+
o Summary
#include <db.h>
void *db_dict_add(dict, name, o_type, o_size, obj)
DICT dict; /* Dictionary pointer */
char *name; /* Name of the object */
int o_type; /* Object type */
int o_size; /* Object size */
void *obj; /* Pointer to the object */
o Description
This function is used to add a new object to a dictionary.
The dictionary is specified by dict. Name is the lookup
name for the object. The o_type is a user specified type
which can be used to group like objects together. The o_size
is the size of the object in bytes. Obj is a pointer to
the object. If sucessful, a new object is created in the
specified dictionary and the contents of obj are copied
to it.
o Returns
A pointer to the new object is returned. If an error occurs,
a NULL pointer is returned and db_error contains the error
code.
+----------------+ ------------------------ +----------------+
| db_dict_delete | - Dict Object Delete - | db_dict_delete |
+----------------+ ------------------------ +----------------+
o Summary
#include <db.h>
void db_dict_delete(dict, name, o_type)
DICT dict;
char *name;
int o_type;
o Description
This function is used to delete an object from the
dictionary dict. Name is the name of the object to
delete. O_type is the type of the object to delete.
There may be mutiple objects with the same name but
different types. If o_type is 0, then all types will
be deleted. If sucessful, the matching object(s) is
removed.
o Returns
The completion status is returned in the global db_error.
A non-zero value indicates an error.
+--------------------+ --------------- +--------------------+
| db_dict_delete_all | Dict Delete All | db_dict_delete_all |
+--------------------+ --------------- +--------------------+
o Summary
#include <db.h>
void db_dict_delete_all(dict, o_type)
DICT dict;
int o_type;
o Description
This function is used to delete all objects of type o_type
from the dictionary dict. If o_type is 0 then all objects
will be removed.
o Returns
The completion status is returned in the global db_error.
A non-zero value indicates an error.
+--------------+ ------------------------- +--------------+
| db_dict_dump | - Dict Dump to a File - | db_dict_dump |
+--------------+ ------------------------- +--------------+
o Summary
#include <db.h>
void db_dict_dump(dict, path, fname)
DICT dict;
char *path;
char *fname;
o Description
This function is used to dump the objects in a dictionary
dict to a file. The file is specified by path and fname.
A new VAR file will be created.
o Returns
The completion status is returned in the global db_error.
A non-zero value indicates an error.
+--------------+ ---------------------- +--------------+
| db_dict_find | - Dict Find Object - | db_dict_find |
+--------------+ ---------------------- +--------------+
o Summary
#include <db.h>
void *db_dict_find(dict, name, o_type)
DICT dict;
char *name;
int o_type;
o Description
This function is used to lookup an object in dictionary
dict. Name is the name of the object to look for and o_type
is the type. If o_type is 0 then the first matching object
of any type will be found.
o Returns
A pointer to the found object is returned. If no matching
object is found, a NULL pointer is returned and an error
code is placed in db_error.
+------------------+ ------------------- +------------------+
| db_dict_find_all | - Dict Find All - | db_dict_find_all |
+------------------+ ------------------- +------------------+
o Summary
#include <db.h>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -