⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db.doc

📁 数据库C语言开发工具包   This archive contains the DB V1.3 file handling C routines. They have been built and
💻 DOC
📖 第 1 页 / 共 4 页
字号:
                int db_dict_find_all(dict, o_type, nlist, olist)

                  DICT    dict;		/* Dictionary		*/

		  int     o_type;	/* Object type		*/

		  char ***nlist;	/* List of object names	*/

		  void ***olist;	/* List of object ptrs	*/







        o Description



		This function is used to retrieve all the objects of type

		o_type from dictionary dict. If o_type is 0, then all

		types will be retrieved. The function allocates space and

		creates a list of pointers to the object names and a list

		of pointers to the objects themselves. Nlist and olist

		will be updated to point to the above two lists resp.

		The two lists should be freed when done with them.  







	o Example



		DICT  dict;

		char *names[], *objs[];

		int   i, cnt;





		cnt = db_find_all(dict, 1, &names, &objs);

		for (i=0; i<cnt; i++)

			printf("name[%d]=%s\n", names[i]);



		free(name);

		free(objs);





        o Returns



		A count of the number of objects found is returned. The

		two pointers nlist and olist are updated to point to the

		list of names and objects resp. If an error occurs, 0

		is returned, nlist and olist are set to NULL and an error

		code is place in db_error.



        +--------------+       ------------------------      +--------------+

        | db_dict_load |       -  Dict Load From File -      | db_dict_load |

        +--------------+       ------------------------      +--------------+







        o Summary



                #include <db.h>



                void db_dict_load(dict, path, fname)

                  DICT  dict;

		  char *path;

		  char *fname;







        o Description



                This function is used to load a dictionary dict with

		objects from a file. The file is specified by path and

		fname. The dictionary must already be initialized. This

		allows multiple loads to a single dictionary. The file

		fname must be an existing VAR type file.







        o Returns



                The completion status is returned in the global db_error. 

                A non-zero value indicates an error.



        +----------+          -------------------------          +----------+

        | db_error |          -  Global Error Status  -          | db_error |

        +----------+          -------------------------          +----------+







        o Summary



                extern int db_error;







        o Description



                This global variable contains the completion status of

                the most recent db_xxxx call. The following values and

                associated constants are defined for V1.3:





			DB_FILE_NOT_FOUND      1

			DB_READ_ERROR          2

			DB_END_OF_FILE         3

			DB_WRITE_ERROR         4

			DB_FILE_NOT_CREATED    5

			DB_FILE_NOT_OPEN       6

			DB_INVALID_BLOCK       7

			DB_BUFFER_ERROR        8

			DB_NO_CURRENT_REC      9

			DB_DELETED_REC        10

			DB_INVALID_FREE       11

			DB_INVALID_BLK_SIZE   12

			DB_INVALID_INDEX      13

			DB_REC_NOT_FOUND      14

			DB_DUP_NOT_ALLOWED    15

			DB_INVALID_REQUEST    16

			DB_INVALID_RANDOM     17

			DB_INVALID_FHDR       18

			DB_VERSION_ERROR      19

			DB_INVALID_LINK       20

			DB_LINK_ERROR         21

			DB_FTYPE_ERROR        22

			DB_INVALID_OPTION     23

			DB_ALLOC_ERROR        24

			DB_VAR_SIZE_ERROR     25

			DB_VAR_CSUM_ERROR     26

			DB_UNSUPP_FEATURE     27

			DB_INVALID_DICT       28

			DB_INVALID_NAME       29

			DB_INVALID_ERROR      30



        +--------------+     ----------------------------    +--------------+

        | db_error_msg |     -  Get Error Message Text  -    | db_error_msg |

        +--------------+     ----------------------------    +--------------+







        o Summary



                #include <db.h>



                char *db_error_msg(error)

                  int   error;







        o Description



                This function is used to get an error message corresponding

                to the error number returned in db_error.







        o Returns



                A pointer to the error message is returned.





        +---------+          --------------------------           +---------+

        | db_find |          -  Find a Record by Key  -           | db_find |

        +---------+          --------------------------           +---------+







        o Summary



                #include <db.h>



                void db_find(df, user_data, key, key_size)

                  DATA_FILE  df;

                  void     *user_data;                   

                  char     *key;

                  int       key_size;







        o Description



                This function is used to find a record by key value. The

                following are inputs:



                     df         -  specifies the data file

                     user_data  -  pointer to the destination buffer

                     key        -  pointer to key value

                     key_size   -  length of the key field



                The key_length field allows for matching less than the

                entire record key in an Index data file. A key_size of zero

                defaults to entire key length. For a Random data file, the

                key_length field is ignored.



                This function is not valid for Sequential ior variable data 

		files.

                





        o Returns



                The data record is read into the buffer pointed to by

                user_data. 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_get_rec_no |    -  Get Relative Record #  -    | db_get_rec_no |

        +---------------+    ---------------------------    +---------------+







        o Summary



                #include <db.h>



                ulong db_get_rec_no(df)

                  DATA_FILE  df;







        o Description



                This function returns the Relative Record Number for the

                Current Record in the data file specified by df. The

                Relative  Record Number for records in sequential data

                files is fixed; however, for records in Index, Random

		and Variable data files the value may be changed due to 

		reorganizations that occur when adds and deletes take 

		place.







        o Returns



                The value of the relative record number is returned.

		For Variable files the rrn is the lseek offsest of the

		record. For the other file organizations, the rrn is

		the actual record number from the beginning of the file.



                If there is an error, a NULL value is returned and the

                global db_error contains the error code.





        +---------+        -------------------------------        +---------+

        | db_open |        -  Open an Existing Data Set  -        | db_open |

        +---------+        -------------------------------        +---------+







        o Summary



                #include <db.h>



                DATA_FILE db_open(path, fname)

                  char *path, *fname;







        o Description



                This function is used to open an existing data file. The inputs

                are as follows:



                     path   -  Path name of data directory

                     fname  -  File name of the data fileo

		

		The path argument can also be treated as a string of 

		defaults.







        o Returns



                This function returns a pointer to the data file descriptor

                block for the data file. This value should be used for future 

                references to the data file.



                If an error occurs a NULL value is returned and the global

                db_error contains the error number.







 

        +-------------+       -------------------------       +-------------+

        | db_read_atr |       -  Read Attribute Data  -       | db_read_atr |

        +-------------+       -------------------------       +-------------+







        o Summary



                #include <db.h>



                void db_read_atr(df, user_data)

                  DATA_FILE  df;                 

                  void      *user_data;







        o Description



                This function is used to read the attribute record for a

                data file. The data file is specified by df and user_data

                points to the destination buffer.



                The attribute data is a single user record that may be 

		used to store some global data for the data file.









        o Returns



                The attribute record is read into the buffer pointed to by

                user_data. The completion status is returned in the global 

                db_error. A non-zero value indicates an error.



        +----------------+     -----------------------     +----------------+

        | db_read_direct |     -  Read by Record #   -     | db_read_direct |

        +----------------+     -----------------------     +----------------+







        o Summary



                #include <db.h>



                void db_read_direct(df, rec_no, user_data, data_size)

                  DATA_FILE  df;                 

                  ulong     rec_no;

                  void     *user_data;

		  int      *data_size;







        o Description



                This function is used to read a record directly by using its

                Relative Record Number. The data file is specified by df,

                the Relative Record Number is rec_no and user_data points

                to the destination buffer.







        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_first |      -  Read First Record  -      | db_read_first |

        +---------------+      -----------------------      +---------------+







        o Summary



                #include <db.h>



                void db_read_first(df, user_data, data_size)

                  DATA_FILE  df;

                  void     *user_data;

		  int      *data_size;





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -