📄 db.doc
字号:
o Description
This function is used to read the first record from a
data file. The data file is specified by df and user_data
points to the destination buffer for the record.
o Returns
The data record is read into the buffer pointed to by
user_data. If the file type is Variable, the length of
the record read is placed in data_size. The read record
becomes the Current Record for this data file. The
completion status is returned in the global db_error.
A non-zero value indicates an error.
+--------------+ ---------------------- +--------------+
| db_read_last | - Read Last Record - | db_read_last |
+--------------+ ---------------------- +--------------+
o Summary
#include <db.h>
void db_read_last(df, user_data, data_size)
DATA_FILE df;
void *user_data;
int *data_size;
o Description
This function is used to read the last record from a
data file. The data file is specified by df and user_data
points to the destination buffer for the record.
o Returns
The data record is read into the buffer pointed to by
user_data. If the file type is Variable, the length of
the record read is placed in data_size. The read record
becomes the Current Record for this data file. The
completion status is returned in the global db_error.
A non-zero value indicates an error.
+--------------+ ---------------------- +--------------+
| db_read_next | - Read Next Record - | db_read_next |
+--------------+ ---------------------- +--------------+
o Summary
#include <db.h>
void db_read_next(df, user_data, data_size)
DATA_FILE df;
void *user_data;
int *data_size;
o Description
This function is used to read the next record from a
data file. The data file is specified by df and user_data
points to the destination buffer for the record.
This function must be preceeded by some function that
establishes the Current Record for the data file. For
example db_read_first followed by db_read_next until end
of file occurs. The value of Current Record is reset to
NONE by a db_add.
o Returns
The data record is read into the buffer pointed to by
user_data. If the file type is Variable, the length of
the record read is placed in data_size. The read record
becomes the Current Record for this data file. The
completion status is returned in the global db_error.
A non-zero value indicates an error.
+--------------+ ---------------------- +--------------+
| db_read_prev | - Read Prev Record - | db_read_prev |
+--------------+ ---------------------- +--------------+
o Summary
#include <db.h>
void db_read_prev(df, user_data, data_size)
DATA_FILE df;
void *user_data;
int *data_size;
o Description
This function is used to read the previous record from a
data file. The data file is specified by df and user_data
points to the destination buffer for the record.
This function must be preceeded by some function that
establishes the Current Record for the data file. For
example db_read_last followed by db_read_prev until end
of file occurs. The value of Current Record is reset to
NONE by a db_add.
db_read_prev should not be used with db_delete. db_delete
positions the current pointer so that a db_read_next will
be correct. A db_read_prev loop with deletes will skip
records.
o Returns
The data record is read into the buffer pointed to by
user_data. If the file type is Variable, the length of
the record read is placed in data_size. The read record
becomes the Current Record for this data file. The
completion status is returned in the global db_error.
A non-zero value indicates an error.
+----------+ --------------------------- +----------+
| db_reorg | - Reorganize Free Space - | db_reorg |
+----------+ --------------------------- +----------+
o Summary
#include <db.h>
void db_reorg(df)
DATA_FILE df;
o Description
When a VAR file record is deleted, the record is marked
as deleted but still remains in the file. This function
is used to reclaim the space held by deleted records.
It is only valid for VAR files.
o Returns
The completion status is returned in the global db_error.
A non-zero value indicates an error.
+-----------+ ------------------------------- +-----------+
| db_update | - Update the Current Record - | db_update |
+-----------+ ------------------------------- +-----------+
o Summary
#include <db.h>
void db_update(df, user_data)
DATA_FILE df;
void *user_data;
o Description
This function is used to update the Current Record for the
data file specified by df. The contents of the data record
pointed to by user_data are written back to the data file.
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_update_atr | - Update Attribute Data - | db_update_atr |
+---------------+ --------------------------- +---------------+
o Summary
#include <db.h>
void db_update_atr(df, user_data)
DATA_FILE df;
void *user_data;
o Description
This function is used to update the attribute record for a
data file. The data file is specified by df and user_data
points to the source buffer to be written to the attribute
area for the data file.
The attribute data is a single user record that may be
used to store some global data for the data file.
o Returns
The completion status is returned in the global db_error.
A non-zero value indicates an error.
+-------------+ ------------------------------ +-------------+
| fname_dflts | - Merge File Name Defaults - | fname_dflts |
+-------------+ ------------------------------ +-------------+
o Summary
char *fname_dflts(fname, dflt)
char *fname, *dflt;
o Description
This function merges a file name string with a
default file name. For example the following would
force a default extension of ".c" if no extension
was present.
x = fname_dflts(fname,".c");
o Returns
A pointer to the resulting static string is returned.
+--------+ ----------------------- +--------+
| fparse | - Parse a File Spec - | fparse |
+--------+ ----------------------- +--------+
o Summary
fparse(fstr, o_node, o_dev, o_dir, o_file, o_ext, o_ver)
char *fstr, *o_node, *o_dev, *o_dir, *o_file, *o_ext, *o_ver;
o Description
This function parses a file specification fstr into component
parts. Not all of these components apply to generic MS-DOS.
o_node - Node name
o_dev - Device name
o_dir - Directory Path
o_file - File name
o_ext - File extension
o_ver - Version number
o Returns
The component strings are copied into the buffers pointed
to by the o_* args.
+------+ -------------------------- +------+
| sort | - Callable Record Sort - | sort |
+------+ -------------------------- +------+
o Summary
void sort_init(rec_size, spec_str)
int rec_size;
char *spec_str;
void sort_release(data_rec)
char *data_rec;
void sort_merge()
char *sort_return(data_rec)
char *data_rec;
o Description
This set of functions provides a callable record sort
facility:
sort_init - Initialize the sort. This must be done first.
rec_size = the size of the data record
spec_str = string of sort specs separated
by commas. "spec,spec,spec..."
spec = XXn.n
||| |
||| +--- size of field (bytes)
||+----- starting position (1 relative)
||
|+------ Format A = Alpha
| U = Unsigned integer
| I = Integer
| R = Real
|
+------- Sequence A = Ascending
D = Descending
sort_release - Release a record to the sort. data_rec
points to the data.
sort_merge - Do the sort merge operation.
sort_return - Return a record from the sort and put
it in data_rec. A pointer to the data
record is returned. A NULL value indicates
end of file.
o Returns
If a sort error occurs an error message is printed and
the program aborts.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -