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

📄 ache.h

📁 Linux 下的socket客户端服务端代码
💻 H
字号:

/*------------------------------------------------------------------------------------
*
*  Copyright(c), 2002-....                      
*    All rights reserved
*                            
*    FILENAME    : ache.h
*    CONTENTS    : header file for the acher 
*  DATE        : 2003/02/1
*  LANGUAGE    : C/C++
*  VERSION        : 1.0
*  AUTHOR      : Xiangbin Lee(Honeycombs)               
*  AUTHOR's EMail:
*                       Honeycombs@263.net
*                       Honeycombs@sina.com
*-------------------------------------------------------------------------------------
* If this code works, it was written by Xiangbin Lee(Honeycombs).
* If not, I don't know who wrote it.       
*-------------------------------------------------------------------------------------
* RECORD:
*  DATE              VERSION                AUTHOR                 CONTENTS
* 2003/02/01          1.0                Honeycombs                Create file
* 2003/03/15          1.1                Honeycombs                flee bugs
*------------------------------------------------------------------------------------*/

#ifndef _ACHE_H
#define _ACHE_H

/***********************************************/
#ifndef EQ
#define EQ ==
#endif

void  SetBuf22(unsigned char *buf, unsigned short data);
unsigned short  GetBuf22(unsigned char *buf);
void  SetBuf44(unsigned char *buf, unsigned long data);
unsigned long  GetBuf44(unsigned char *buf);
void  SetBuf43(unsigned char *buf, unsigned long data);
unsigned long  GetBuf43(unsigned char *buf);

#define EXTRANS_FP_HEAD        0x01
#define EXTRANS_FP_TAIL        0x02
#define EXTRANS_CP_HEAD        0x03
#define EXTRANS_CP_TAIL        0x04

/* password inche */
void TransPass(unsigned char *lpbuf, int buflen, unsigned short randid);
/* trans packet */
int TransPacket(unsigned char *dest, unsigned char *source, int scrlen); 
int ExTransPacket(unsigned char *dest, unsigned char *source, int scrlen);
int AchbufToPktbuf(unsigned char *dest, unsigned char *frame, int framelen);
int PktbufToAchbuf(unsigned char *dest, unsigned char *buf, int buflen);
/*------------------------------------------------------------*/
/* define for achstaus write mode */
typedef unsigned char ACHE_MODE;
#define ACHE_AS_STACK    0xF1 
#define ACHE_AS_QUEUE    0xF2

#define ACHE_READER        0xF1
#define ACHE_WRITER        0xF2

#define ACHERW_TRANS    0xF1
#define ACHERW_NOTRANS    0xF2

#define ACHE_REGSIGNE    0xF8
#define ACHE_USESIGNE    0xE9

typedef struct _ACHSTATUS
{
    unsigned char *ACHBuffer;
    
    unsigned long ACHCOUNT;
    unsigned long windex;
    unsigned long rindex;
    unsigned long MaxBufLen ;
    unsigned char head;
    unsigned char tail;
    unsigned char perbyte;
    ACHE_MODE      achemode ;
    int readtype    ;
    int writetype    ;
    int state ;
}ACHSTATUS,*LPACHSTATUS;

int  ResetAchStatus(
                    ACHSTATUS *sta,
                    unsigned char *dest,
                    unsigned long maxbuflen,
                    unsigned char fhead,
                    unsigned char ftail,
                    unsigned char fperbyte
                    );

ACHE_MODE  SetAcheMode( ACHSTATUS *achSta, ACHE_MODE amode, int rtype/*=ACHERW_NOTRANS*/, int wtype /*=ACHERW_NOTRANS*/);
int   ReaderAche( ACHSTATUS *achSta, unsigned char * buffer);
int   WriterAche( ACHSTATUS *achSta, unsigned char * buffer, int length);

/***********************************************************************************/
typedef struct _PACKETACHE
{
    unsigned long paklen;
    unsigned long id;
    struct _PACKETACHE *next;
    struct _PACKETACHE *prev;
}PACKETACHE,*LPPACKETACHE;

typedef struct _PKTACHSTATUS
{
    unsigned long PKTCOUNT;
    unsigned long MaxPktCount ;
    unsigned char *ACHBuffer;
    unsigned long ACHCOUNT;
    unsigned long MAXACHCOUNT ;
    unsigned long wid;
    ACHE_MODE      achemode ;
    PACKETACHE *pkthead;
    PACKETACHE * rindex;
    PACKETACHE * windex;
}PKTACHSTATUS,*LPPKTACHSTATUS;

int  ResetPktAchStatus(PKTACHSTATUS *pktsta);

int  CreatePktAchStatus(
    PKTACHSTATUS *pktsta,
    unsigned char *dest,
    unsigned long MaxPktCount,
    unsigned long MAXACHCOUNT
    );

ACHE_MODE  SetPktAcheMode( PKTACHSTATUS *achSta, ACHE_MODE amode);
int   ReaderPktAche( PKTACHSTATUS *pktsta, unsigned char * buffer);
int   WriterPktAche( PKTACHSTATUS *pktsta, unsigned char * buffer, int length);

/***********************************************************************************/

typedef struct _CIRCLEACHE
{
    unsigned long id;
    void *lppoint;
    struct _CIRCLEACHE *next;
    struct _CIRCLEACHE *prev;
}CIRCLEACHE,*LPCIRCLEACHE;

typedef struct _CIRCLEACHESTATUS
{
    unsigned char ifinit ;
    unsigned long pocount;
    CIRCLEACHE *head;
    CIRCLEACHE * rid;
    CIRCLEACHE * wid;
}CIRCLEACHESTATUS,*LPCIRCLEACHESTATUS;

int   ResetCircleAche(CIRCLEACHESTATUS *lpsta);
void  *GetCurCircleAche( CIRCLEACHESTATUS *lpsta);
unsigned long GetCurCircleAcheIndex( CIRCLEACHESTATUS *lpsta);
unsigned long  GetCircleAcheCount( CIRCLEACHESTATUS *lpsta);
void  *GetCircleAche( CIRCLEACHESTATUS *lpsta, unsigned long nWitch);
unsigned long AddCircleAche( CIRCLEACHESTATUS *lpsta, void *lpoint);
unsigned long DelCircleAche( CIRCLEACHESTATUS *lpsta, void *lpoint);

/*-----------------------------------------------------------------*/
void *MallocWinProCircleAche(unsigned long wnd, unsigned long buflen);
int FreeWinProCircleAche(unsigned long wnd);
void *FindWinProCircleAche(unsigned long wnd);

#endif

⌨️ 快捷键说明

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