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

📄 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


#define _SYS_UNIXOS
/*------------------------------------------------------------------------------------*/

typedef struct _C8BIT
{
    unsigned char bit0:1;
    unsigned char bit1:1;
    unsigned char bit2:1;
    unsigned char bit3:1;
    unsigned char bit4:1;
    unsigned char bit5:1;
    unsigned char bit6:1;
    unsigned char bit7:1;
}C8BIT,*LPC8BIT;

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 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 _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 CircleAcheResetRead(CIRCLEACHESTATUS *lpsta);
void CircleAcheResetWrite(CIRCLEACHESTATUS *lpsta);

void *GetCircleAche( CIRCLEACHESTATUS *lpsta, unsigned long nWitch);
unsigned long AddCircleAche( CIRCLEACHESTATUS *lpsta, void *lpoint);
unsigned long DelCircleAche( CIRCLEACHESTATUS *lpsta, void *lpoint);

/*-----------------------------------------------------------------*/

#define DEFAULT_WINPRO_IDENT     0xFFFFFFFF

typedef struct _WINPRO_ACHE
{                   
    unsigned char cir_sign[5];
    CIRCLEACHESTATUS cir_ache;
}WINPRO_ACHE, *LPWINPRO_ACHE;
                           

void *MallocWinPro(WINPRO_ACHE *lpro, unsigned long wnd, unsigned long buflen);
int FreeWinPro(WINPRO_ACHE *lpro, unsigned long wnd);
int FreeAllWinPro(WINPRO_ACHE *lpro);
void *FindWinPro(WINPRO_ACHE *lpro, unsigned long wnd);
void *FirstWinPro(WINPRO_ACHE *lpro);
void *NextWinPro(WINPRO_ACHE *lpro);
int GetWinProCount(WINPRO_ACHE *lpro); 
unsigned long ResetWinProIdent(WINPRO_ACHE *lpro, unsigned long wnd, unsigned long newnd);
unsigned long CheckWinPro(WINPRO_ACHE *lpro, void *lprec);


/*
 * Tree buffer cache
 *
 *
 *
 *
 */

#define ACHETREE_ITEMDATA(hi, low)  ((((hi)&0xFFFF)<<16)|((low)&0xFFFF))

/* define for tree type */
#define ACHETRTEE_SINGLE    ((unsigned char)0x01)
#define ACHETRTEE_LEAFE        ((unsigned char)0x02)
#define ACHETRTEE_ROOT        ((unsigned char)0x03)
#define ACHETRTEE_NORMAL    ((unsigned char)0x04)

typedef struct _ACHETREE
{
    /* private data segment */
    struct _ACHETREE *lpParent;
    struct _ACHETREE *lppre;
    struct _ACHETREE *lpnext;
    struct _ACHETREE *lpChild ;
    int index;

    unsigned short curChildNum;
    unsigned char type ;
    unsigned char ifinit ;


    /* user data segment */
    unsigned long ident;
    unsigned long usrdata;
    void *lpData ;
    int datalen ;
}ACHETREE, *LPACHETREE;

/*
 * Init root tree
 */
int InitAcheTree(ACHETREE *lptree);


/*
 * reset tree type
 */
int ResetTreeType(ACHETREE *lptree);


/*
 * Set and get Tree data
 */
int SetAcheTreeData(ACHETREE *lptree, unsigned long data);
int GetAcheTreeData(ACHETREE *lptree, unsigned long *lpdata);

/*
 * Set and get Tree text
 */

int SetAcheTreeText(ACHETREE *lptree, char *lptxt);
int GetAcheTreeText(ACHETREE *lptree, char *lptxt);

/*
 * get child from parent tree acording to the index inform
 */
ACHETREE *GetChildTree(ACHETREE *lparent, int index);

/*
 * get the root of a normal tree or leaf
 */
ACHETREE *GetRootOfTree(ACHETREE *lptree);


/*
 * cut the relation between tree and it's parent
 */
int CutTreeRelation(ACHETREE *lptree);

/*
 * insert an existent tree to another as a child
 * this tree must has no neighbours, otherwise we cut
 * the relations between this tree and its parent
 */
int LinkToTree(ACHETREE *lparent, ACHETREE *lptree, int index);

/*
 * deep query the tree
 */
int DeepQueryAcheTree(ACHETREE *lptree, int (*useFunction)(ACHETREE *), int ifqueryself);

/*
 * wide query the tree
 */
int WideQueryAcheTree(ACHETREE *lptree, int (*useFunction)(ACHETREE *), int ifqueryself);


/*
 * insert an item of text
 */

ACHETREE * AcheTreeInsertItem(ACHETREE *lparent,char *lptext,int index);

/*
 * delete all items of tree
 */

int AcheTreeDelItems(ACHETREE *lparent);


#endif


⌨️ 快捷键说明

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