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

📄 memdatabase.h

📁 Unix 环境下用C语言实现的内存数据库。
💻 H
字号:
#ifndef MEMDATABASE_H#define MEMDATABASE_H#include <stdio.h>#include <sys/sem.h>#include <sys/shm.h>#include "ErrCode.h"#define FPOS( type, field ) ( (int)&(( type *) 0)-> field )#define FLEN( type, field ) ( sizeof((( type *) 0)-> field ))#define SetKeyMemDB(p,type,field) ( SetTableKey(p,FPOS(type,field),FLEN(type,field)) )#define DeclareCursorMemDB(p,type,field,value) ( DeclareTableKey(p,FPOS(type,field),FLEN(type,field),(void*)value) )#define MAX_FETCHKEY_NUM      10#define MAX_FETCHVALUE_LEN    256typedef struct{    int iKeyOffSet;       /* The Key field offset */    int iKeyLen;          /* The Key field len */    char sValue[MAX_FETCHVALUE_LEN];  /* The Value of Fetch Key */}FETCH_KEY_DEF;typedef struct{    int iIpcKey;       /* The key of ShareMemory and Semphore */    int iShmId;        /* The Id of ShareMemory */    int iSemId;        /* The Id of Semphore */    long lFetchNum;    /* The Index of Fetch */    int iFetchKeyNum;  /* The Fetch Key Number */    FETCH_KEY_DEF stuFetchKeyBuf[MAX_FETCHKEY_NUM];   /* The Declare Fetch Key Define */    char *pShmArea;    /* The Point to ShareMemory */}MEMDATABASE;int CreateMemDB(MEMDATABASE **pMemDB,char *pTableName,int iIpcKey,long lMaxRecord,int RecordLen);int DropMemDB(MEMDATABASE *pMemDB);int AttachMemDB(MEMDATABASE **pMemDB,int iIpcKey);int FetchCursorMemDB(MEMDATABASE *pMemDB,char *pInBuffer);int CloseCursorMemDB(MEMDATABASE *pMemDB);int SelectOneMemDB(MEMDATABASE *pMemDB,char *pInBuffer);int SelectMemDB(MEMDATABASE *pMemDB,char *pInBuffer);int UpdateMemDB(MEMDATABASE *pMemDB,char *pInBuffer);int DeleteMemDB(MEMDATABASE *pMemDB,char *pInBuffer);int DeleteOneMemDB(MEMDATABASE *pMemDB,char *pInBuffer);int InsertMemDB(MEMDATABASE *pMemDB,char *pInBuffer);void TruncateMemDB(MEMDATABASE *pMemDB);#endif

⌨️ 快捷键说明

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