📄 protocal.h
字号:
/*
*
* Copyright (C) 2003 Xiangbin Lee <honeycombs@sina.com> <honeycombs@263.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation.
*/
#ifndef _PROTOCAL_H_
#define _PROTOCAL_H_
#include "packet.h"
#define IOB(a) ((a)>>3)
#define LOB(a) ((a)-(((a)>>3)<<3))
#define BOB(a) (IOB(a)+(LOB(a)!=0))
#define BLOI(a) (a<<3)
// memory type for pdsdata
#define PDSMEMTYPE_AUTO 0 // auto malloc
#define PDSMEMTYPE_STATIC 1 // static memory
#define PDSMEMTYPE_TRANS 2 // from parent
typedef struct _PDSDATA
{
unsigned int nID; // protocal head id
unsigned char memtype; // memory type
unsigned long length; // protocal length (bit longth)
unsigned short nhbits; // no used length of bits
unsigned short sibits; // signed length of bits
unsigned char *lpbuf; // point to protocal data
void *lparam; // point to protocal param
}PDSDATA, *LPDSDATA;
typedef struct _PDS
{
unsigned char reg;
/* register sign */
PDSDATA type;
/* Hhead of data (const only)
nID = protocal head ident code, must be set const
memtype = memory type
nhbits = no used data length of buffer
sibits = child buffer position from parent
length =is protocal head length, must be set const
lpbuf = protocal head, must be set const
lparam = type param for this type only, must be set const
*/
PDSDATA p_data;
/* main pase data
nID = 0
memtype = memory type
nhbits = no used data length of lpbuf left
sibits = comp protocal type position for child
length = p_data data length, must be set from function Pdata return
lpbuf = p_data data, must be set const
lparam = point to system param, must be set const
*/
CIRCLEACHESTATUS cldPDS; // child mulitePDSs
CIRCLEACHESTATUS parPDS; // parent PDSs
int (*PF_type)(PDSDATA *);
/*
PF_type: special function for this type, must be set const
input: PDSDATA type
output: depend on function
return: 0 - success, others - error nummber
*/
PDSDATA* (*PF_trans)(PDSDATA *);
/*
PF_trans: Pretranslated p_data, must be set const
input: PDSDATA p_data
return: point to PDSDATA translated, depend on function
*/
int (*PF_data)(PDSDATA *);
/*
PF_type: main parse of this PSD
input: PDSDATA p_data
output: depend on function
return: 0 - success, others - error nummber
*/
}PDS,*LPDS;
int ReadBits( // read bits from source
unsigned char *dest, // point to dest buffer
unsigned char *src, // point to dest buffer
unsigned short bitsfrom, // start bits from head of source buffer
unsigned int bitleng); // read length (bit)
int CmpBits(
unsigned char *buf1, unsigned short bf1, // point to dest buffer
unsigned char *buf2, unsigned short bf2, // point to dest buffer
unsigned int bitleng);// comp length (bit)
unsigned int GetPDSChildCount(PDS * lpPds);
PDS *GetCurChildPDS(PDS * lpPds);
void RewindPDSChild(PDS * lpPds);
unsigned int AddPDSChild(PDS * lpPds, PDS * lpCld);
unsigned int DelPDSChild(PDS * lpPds, PDS * lpCld);
void DelallPDSChild(PDS * lpPds);
void DisbandPDS(PDS * lpPds);
int PDSParse(PDS * lpPds);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -